1

I am using bootstrap collapse that will show when click on the related button. the problem is this collapse does not work mutually. I want that only one collapse will be shown at a time and hide all others.

although the Accordion example is available it will not work on buttons. I am a newbie in bootstrap maybe I am doing in the wrong way.

this is my jsfiddle

<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExampleTwo" aria-expanded="false" aria-controls="collapseExampleTwo"> Button with data-target </button> <div class="collapse" id="collapseExampleTwo"> <div class="well"> <div><p>2nd div</p></div> </div> </div> 

how I show collapse only one at a time.

2
  • 1
    for your requirement go with Accordion, and style your accordion tabs accordingly. Commented Apr 8, 2015 at 10:26
  • is this is not possible with button ? Commented Apr 8, 2015 at 10:34

1 Answer 1

3

Try this:

$('.btn-primary').on('click',function(){$('.collapse').collapse('hide');}) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.