[英]jQuery $('element', this) selector, what does it mean?
我在函數中使用了這個選擇器,我什至不知道它到底意味着什么,但是它起作用了-這是我的代碼:
else if($(this).hasClass('list')) { listItem.stop(true,true).fadeOut(333, function(){ var $this = $(this); if(listItem.hasClass('grid')) { $this..insertBefore($this.children()); }
“ .find()”方法僅注意一個參數,因此它的含義與
$this.find('h1')
JavaScript不在乎是否向函數傳遞了太多參數。 實際上,沒有“太多爭論”這樣的概念。
您可以在$()
函數中使用上下文,如下所示:
$('element', this)
它會那么只有該元素的繼承人生中搜索this
referens來。
等效於使用find
方法:
$(this).find('element')
但是,將find
與兩個參數一起使用是沒有意義的。 它只會忽略第二個參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.