Bootstrap Collapse - Expand All

pedalGeoff

I've implemented Bootstrap 3 Collapse. The client wants all of the target blocks to expand when any one of the heading links is clicked. I have tried to implement a modified version of this answer, but can't get it working.

How can I get all target blocks to expand/collapse when any one of them is clicked?

This is the markup:

<div class="panel-group" id="accordion">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h6 class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href="#collapse{entry_id}">{title}</a></h6>
        </div>
    </div>
    <div id="collapse{entry_id}" class="panel-collapse collapse">
      <div class="panel-body">
        {technology_body}
      </div>
   </div>
</div>

And this is the JS I have attempted:

$('#accordion').on('click', function() {
    if($('.collapse:not(.in)')) {
         $.collapse("toggle");
    }
});
pedalGeoff

I got some help offline on this question. The script to use is

$('#accordion .panel-default').on('click', function () {
    $('#accordion .panel-collapse').collapse('toggle');
});

and this is the JSFiddle example http://jsfiddle.net/gtowle/Vq6gt/1/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive