Jump to content

How to open accordion section from an external link?


michaelmueller4321

Recommended Posts

  • 2 weeks later...

When the page loads your ready function will run, this should open the accordion section the URI's hash refers to:

jQuery(document).ready(function() {
    // get the #section from the URL
    var hash = window.location.hash; 
    // open accordion
    jQuery(hash).slideDown(300).addClass('open'); 
    // set title to active 
    jQuery(hash).prev('.accordion-section-title').addClass('active');
    /* ... the rest of your code here */
});

you might get a slight performance boost if you don't get the jQuery object twice, you can chain these like this:

jQuery(hash).slideDown(300).addClass('open')
                .prev('.accordion-section-title').addClass('active');

 

Edited by ishan_shah
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...