I want to collapse a div with a button if it is not collapsed already. I have a button:
<button data-toggle="collapse" data-target="#aim" ...></button>
and my div
:
<div id="#aim" class="collapse"></div>
I works great but if the div
is already open the button close it.
Is there a chance to get collapse it when it isn't already?
My solution:
<button data-toggle="collapse" data-target="#aim" ...></button>
<div id="aim" class="collapse in"></div>
so when you use collapse in
instead of collapse
it only expands and do not minimize itselfs again when it already expanded.
Remove the #
from your <div id="#aim" class="collapse">
and it should work. More info about bootstrap's data-toggle attribute can be found here.
(Previous comment added as possible answer to help close this question).
Use Javascript with on click and hide().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With