patrick
patrick

Reputation: 657

Jquery Selectors + Syntax

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/

Upvotes: 2

Views: 117

Answers (3)

Dennis
Dennis

Reputation: 32598

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

should be

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

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

Upvotes: 0

expertCode
expertCode

Reputation: 533

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 ;)

Upvotes: 1

CambridgeMike
CambridgeMike

Reputation: 4622

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

$('img', this)...

Upvotes: 4

Related Questions