I am having some problems configuring the jQuery .slideToggle to only open one div per click. I have two links – each link toggles open/close a separate div – however if one div is open, and the link to toggle the second div is clicked, they both remain open and stacked on each other.
My goal is to configure this to only allow one div to be toggled open at a time. If the first div is open—clicking the link to toggle the second will close the open div.
It seems to be something quite simple, but I can’t seem to wrap my hands on it. Any help is much appreciated. Thank you.
I have removed the duplication that you have going on in your code, so that way it doesn’t matter how many list items you have; the one function will work. I’d love for someone who knows more about jQuery to step in and suggest improvements.
This reply has been reported for inappropriate content.
Thanks for the reply. That seems to actually work… however… I’m wondering if there is a better solution to the ‘delay’ method. I think the toggle should fire immediately when the link is clicked rather than having the delay – I do understand it is needed for your method to function correctly. Thanks