开发者

Jquery Selectors + Syntax

开发者 https://www.devze.com 2023-04-09 03:25 出处:网络
I am trying to use a jQuery selector (this) to get an image nested on the same level. Just a syntax error, any help开发者_开发问答 would be appreciated. Thanks!

I am trying to use a jQuery selector (this) to get an image nested on the same level. Just a syntax error, any help开发者_开发问答 would be appreciated. Thanks!

        $(this).addClass('on');
        $(this img).slideUp('fast');
        $(this img.accordionButtonActive).slideDown('fast');

http://jsfiddle.net/zBrhH/


You can't do $(this img). But you can pass a second parameter which defines the scope, try this:

$('img', this)...


I think you want the effect like this:

http://jsfiddle.net/expertCode/zBrhH/

using:

    $(this).addClass('on');
    $('img', this).slideUp('fast');
    $('img.accordionButtonActive', this).slideDown('fast');

I changed some events too. Try it ;)


    $(this img).slideUp('fast');

should be

    $(this).find("img").slideUp('fast');

Demo, with working accordion: http://jsfiddle.net/zBrhH/2/

0

精彩评论

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

关注公众号