user4630 user4630 - 2 years ago 120
Javascript Question

Show/Hide/Toggle Multiple Divs By ID?

The good folks at stackoverflow helped me part of the way with this, now i just need a little push over the finishing line.

I need to have a toggle button, that opens div on click (slide down) and then closes on click, pref with an active class too.

However, if you click another toggle button that child div opens and closes the previous one, IF it was open.

So basically none of the opening divs can ever be open at the same time, only one at a time.

I need this done by anchor id as the opening div is not related to the toggle button (its down the page a bit)

So far that doesn't work, but all the html is there..

Thank you so much if anyone can help, searched high and low and the nearest i found was this but it doesnt close an already open div when you click a new one.

Answer Source


    var myelement = $(this).attr("href")



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download