I’ve recently bought ‘Smashing jQuery’ by Jake Rutter – it’s a good book, but I’m stuck modifying a bit of ‘Accordion’ code.
When a section is clicked it expands as intended, but if clicked a second time (while still open) it closes only to instantly open again.
I want the expanded section to close if it’s clicked a second time, only opening again if it’s clicked. Hope this makes sense. Any help would be much appreciated.
Please see the demo URL below for an example and code I’ve used.
http://demos.d3-creative.com/accordion/accordion-1.html
You would need something like below to make it work. See the comments:
And add
display:noneto#accordion .accordion-content