开发者

Trying to put a variable in a selector in Jquery

Im trying to put a variable开发者_如何学JAVA in a selector but it doesn't work what am i doing wrong?

<a class="button left" href="#">left</a>
<a class="button right" href="#">right</a>


$('.button:not(.disable)').show(); //Works

var oButtons = $('.button');
$(oButtons+':not(.disable)').show(); //Doesn't Work why?


because you are trying to pass a jquery object into another jquery object. what you want to do is this:

var oButtons = '.button';
$(oButtons+':not(.disable)').show();


well you could use something like this:

var oButtons = $('.button');
oButtons.filter(':not(.disable)').show(); //Notice the filter option
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜