forum

Home / DeveloperSection / Forums / How to toggle next hidden div on click

How to toggle next hidden div on click

Anonymous User 1572 28-Jan-2015

I have the following setup. I want to toggle the expanded div when clicking the expander link. I only want to expand the div directly next to the link though. How can I do this?

<a class="expander" href="#"><?php echo get_the_title($post->ID); ?></a>
<div class="expanded">
    content here
</div>
 
<a class="expander" href="#"><?php echo get_the_title($post->ID); ?></a>
<div class="expanded">
    content here
</div>
 
<a class="expander" href="#"><?php echo get_the_title($post->ID); ?></a>
<div class="expanded">
    content here
</div>

Here's my jquery:

$('.expander').click(function() {
    event.preventDefault();
    $(this).siblings('expanded').toggle();
});


Updated on 28-Jan-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By