Skip to content

Instantly share code, notes, and snippets.

@lambdamusic
Last active April 4, 2024 22:04
Show Gist options
  • Save lambdamusic/4734346 to your computer and use it in GitHub Desktop.
Save lambdamusic/4734346 to your computer and use it in GitHub Desktop.
JavaScript: JQuery Accordion: retrieve active tab / open dynamically #js
// imagine the accordion is started like this:
$("#accordion").accordion({ header: 'h5', collapsible: true , active: false});
// this gets you the index of open accordion [0.....n]
$("#accordion h5").index($("#accordion h5.ui-state-active"));
// let's save that index.. and use it to activate/deactivate the tab
n = $("#accordion h5").index($("#accordion h5.ui-state-active"));
$('#accordion').accordion('activate', n);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment