Hello. Googled this topic, found solutions like this . There is one drawback. If initially, in the example by reference, open the 2nd block, then click hide all, then reveal all - the 2nd block will not open. I understand that this is because of the selector with the generated class. I tried the jQuery('body').on('click', '.closeall', ...) - the effect is the same. Removing part of the selector and leaving jQuery('.accordion-body') is also not an option, already opened blocks will jump when expanded. How can I fix this?

    1 answer 1

    It is enough to remove the excess part from the selector and it will work.

    It was :

     $('.closeall').click(function(){ $('.panel-collapse.in') .collapse('hide'); }); $('.openall').click(function(){ $('.panel-collapse:not(".in")') .collapse('show'); }); 

    It became :

     $('.closeall').click(function(){ $('.panel-collapse.in') .collapse('hide'); }); $('.openall').click(function(){ $('.panel-collapse') .collapse('show'); }); 
    • The only problem is that when you first click, open everything, the first one on the contrary collapses - MasterAlex
    • @MasterAlex bootply.com/CQpSkZkQVR - Zhukov Roman
    • That's better :) - MasterAlex