简体   繁体   中英

Bootstrap3 accordion collapse: how to show opened div at the top?

I have just implemented bootstrap collapse(accordion) which works very well. Every element has huge amount data, so that the data can't show from first

Is there any option to show element at the top when open accordion ?

Opened div should be top of the page

Demo http://bootply.com/84308

You could capture the 'shown' event and use jQuery to move the selected panel to the first position in the accordion like this..

$('#accordion').on('shown.bs.collapse', function () {

  var openPanel = $(this).find('.in').parents('.panel');
  openPanel.prependTo('#accordion');

});

Demo: http://bootply.com/84308

You can add "in" class to your inner div to display data. recommend you to go through the link http://getbootstrap.com/2.3.2/javascript.html#collapse

Please add more details to your problem if this does not helps you. Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM