第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

jQuery選擇器中的“上下文”是什么?

jQuery選擇器中的“上下文”是什么?

達(dá)令說 2019-09-21 15:28:29
之間有什么區(qū)別$('input.current_title', '#storePreferences').prop('disabled', false);和$('#storePreferences input.current_title').prop('disabled', false);?
查看完整描述

2 回答

?
偶然的你

TA貢獻(xiàn)1841條經(jīng)驗 獲得超3個贊

有什么區(qū)別$('input.current_title', '#storePreferences').prop('disabled', false);和$('#storePreferences input.current_title').prop('disabled', false);?


是的,但是很微妙

區(qū)別在于如何選擇元素。


$('input.current_title', '#storePreferences');

等于1:


$('#storePreferences').find('input.current_title');

但不等同于:


$('#storePreferences input.current_title');

即使相同的元素也會受到影響。


它們之所以不同,是因為using find允許將上下文返回到#storePreferenceswhen end調(diào)用。


1:jQuery v1.9.1源代碼中的194-202行

// HANDLE: $(expr, $(...))

} else if ( !context || context.jquery ) {

    return ( context || rootjQuery ).find( selector );


// HANDLE: $(expr, context)

// (which is just equivalent to: $(context).find(expr)

} else {

    return this.constructor( context ).find( selector );

}

根據(jù)您的問題,將修改相同的元素,因此功能上沒有差異,但重要的是要意識到所使用選擇器的廣泛含義。


查看完整回答
反對 回復(fù) 2019-09-21
  • 2 回答
  • 0 關(guān)注
  • 702 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號