JQuery Accordion: retrieve active tab / open dynamically


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // imagine the accordion is started like this:
  2. $("#accordion").accordion({ header: 'h5', collapsible: true , active: false});
  3.  
  4.  
  5. // this gets you the index of open accordion [0.....n]
  6. $("#accordion h5").index($("#accordion h5.ui-state-active"));
  7.  
  8. // let's save that index.. and use it to activate/deactivate the tab
  9. n = $("#accordion h5").index($("#accordion h5.ui-state-active"));
  10. $('#accordion').accordion('activate', n);

URL: http://jqueryui.com/demos/accordion/#method-activate

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.