I need to add some accordian style expand/collapse handles to a series of parent container divs in my application. Is this something that's too simple for a library like jquery?
Example:
<div class="handleDiv"> expand | collapse
<div>child element</div>
<div>child element</div>
</div>
<div class="handleDiv"> expand | collapse
<div>child element</div>
<div>child element</div>
</div>
To make an animated collapsible, add max-height: 0 , overflow: hidden and a transition for the max-height property, to the panel class.
Just add data-toggle="collapse" and a data-target to element to automatically assign control of a collapsible element. The data-target attribute accepts a CSS selector to apply the collapse to. Be sure to add the class collapse to the collapsible element. If you'd like it to default open, add the additional class in.
The collapse JavaScript plugin is used to show and hide content. Buttons or anchors are used as triggers that are mapped to specific elements you toggle. Collapsing an element will animate the height from its current value to 0 .
I have just wrote a plugin to do that.
See http://sylvain-hamel.github.io/simple-expand/
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