Skip to main content

Custom Accordion



I have the accordion below which works but when an item is open if you click it again it re opens instead of closing.





I'm not sure of the best way to adapt the code below to achieve this?





Any help or advice would be great?





Thanks







$('.acc h2').click(function() {

$('.acc h2.open').nextUntil('h2').stop(true, true).slideToggle();

$('.acc h2.open').removeClass('open');

$(this).nextUntil('h2').stop(true, true).slideToggle(900);

$(this).toggleClass('open');

});



<div class="acc">



<h2>1. Title 1</h2>

<div><p>text 1</p></div>



<h2>2. Title 2</h2>

<div><p>text 2</p></div>



<h2>3. Title 3</h2>

<div><p>text 3</p></div>



</div><!--END acc-->




Comments

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?