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