簡體   English   中英

jQuery $('element',this)選擇器,這是什么意思?

[英]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與兩個參數一起使用是沒有意義的。 它只會忽略第二個參數。

它是替代 jQuery 選擇器上下文選擇器上下文

.find()方法將忽略選擇器以外的任何其他參數。 它的搜索上下文節點作為函數調用的上下文給出。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM