开发者

JQuery slideToggle on a class

i have a problem with the slideToggle effect on my site.

I have assigned the effect to a class but when one link is clicked it is opening every content block which has that specific class.

Is there anyway that you can assign this effect to a class and have them open when each specific one is clicked.

Please view at the following url; http://www.presentationplayer.info

Note: Don't use In开发者_如何学Pythonternet Explorer as the site has'nt been tested in the browser at the moment


This code performs a slideToggle on everything that has the class article_content:

$('.article_content').slideToggle();

So what you need to do instead is traverse up in the hierarchy to find the parent article and then traverse down to the corresponding article content under it, then finally call slideToggle on that:

$(document).ready(function() {
    $('.article_title a').click(function() {
        $(this).closest('article').find('.article_content').slideToggle();
        $(this).innerHTML = 'close';
    });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜