Monkey
Monkey

Reputation: 23

Setting only one div to open on slide toggle

I've set 3 blog posts so that extra content is hidden but then on click slideToggle's down, the problem is, this happens on every element that has the same class.

I can't seem to figure out how to make it so that only one will slide at a click.

$(document).ready(function(showmenu) {
        $('.post-footer').click(function() {
                $('.post-more-content').slideToggle().delay('500');
                setTimeout(function(){$('.post-more-content').slideToggle()}, 30000);
     });

});

http://jsfiddle.net/0wu05743/

Upvotes: 2

Views: 208

Answers (1)

thecodeparadox
thecodeparadox

Reputation: 87073

Try this:

$(document).ready(function (showmenu) {
    $('.post-footer').click(function () {
        $(this) // clicked element
            .parent('article') // move to parent <article>
            .find('.post-more-content') // getting more content holder <div>
                                           // of current <article>
            .slideToggle();
    });
});

Demo

Upvotes: 1

Related Questions