How do I show/hide next div? The following code works:
jQuery(".edittopic").click(function() {
jQuery(this).next(".t_edit_cont").toggle();
});
... only if the t_edit_cont
div is right after the edittopic
button. Currently, I have them in separate DIVs, like this:
<div class="t_mod_box">
<input type="submit" value="Edit" class="edittopic" name="send" />
</div>
<div class="t_edit_cont">
Show hide content inside here...
</div>
How can I make this work? jsfiddle demo.
I think so you want show hide as you want your FAQ, hopefully this is helpful for you
http://jsfiddle.net/indianwebdesigner/yhvm4duq/
if not then please leave a message
HTML
jQuery
Need to select parent before doing
.next()
DEMO
You can use
parent()
to point jQuery in the right path:Yet, a cleaner and more reliable approach would be to associate the clicked button and the div somehow.
For example (using
data-
attributes):Then: