Skip to content

Instantly share code, notes, and snippets.

@wernersmit
Created February 19, 2017 15:55
Show Gist options
  • Save wernersmit/08a11430add7604c497ba07a22898c8e to your computer and use it in GitHub Desktop.
Save wernersmit/08a11430add7604c497ba07a22898c8e to your computer and use it in GitHub Desktop.
Open next panel in jQuery accordion programatically
/*
* Source: http://stackoverflow.com/questions/11041420/how-to-programmatically-open-jquery-accordion-content-panel
*/
var $accordion = $("#accordion").accordion();
function openNextAccordionPanel() {
var current = $accordion.accordion("option","active"),
maximum = $accordion.find("h3").length,
next = current+1 === maximum ? 0 : current+1;
// $accordion.accordion("activate",next); // pre jQuery UI 1.10
$accordion.accordion("option","active",next);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment