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/
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/
精彩评论