runners3431
runners3431

Reputation: 1455

jquery accordion - How to activate a panel based on active class inside the panel?

So I have a jquery accordion based off h2s and an unordered list. Inside the list, there is a list item that has an a href with active class associated with it.

Is there way to get the jquery accordion to fire the correct panel if it has an active class?

Upvotes: 0

Views: 2429

Answers (1)

Jay
Jay

Reputation: 6294

You will want to get the index of your active class and use the "active" option on the accordion.

function setActive() {
    var index = $('#myaccordion li').index($('#myaccordion li.activeClass'));
    $('#myaccordion').accordion("option","active" index);
}

For more information you can look here and here. Hope this helps.

Upvotes: 2

Related Questions