开发者

Chaining the JQuery object [$(this)] and other objects

How do I chain the jQuery object with another object such as this:

($(this) AND $('#foo')).hide();

Is this possible开发者_运维知识库?


I think you're looking for .add()

$(this).add('#foo').hide();

EDIT

Interestingly enough, you can't start with "this". Must be something to do with the element. That having been said (and for now) use the following:

<a href="#">Hide both</a>
<div id="foo">
    Additional content to hide
</div>
$('a').click(function(){
    $('#foo').add(this).hide();
});

Proven to work. Meanwhile, I'm going to see what I can find about why the previous version doesn't work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜