欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery初學(xué):find()方法及children方法的區(qū)別分析

 更新時(shí)間:2011年01月31日 23:19:42   作者:  
總經(jīng)一下前段時(shí)間用于的jQuery方法:find及children。需要的朋友可以參考下。
首先看看英文解釋吧:
children方法:

find方法:

通過以上的解釋,可以總結(jié)如下:
1:children及find方法都用是用來獲得element的子elements的,兩者都不會(huì)返回 text node,就像大多數(shù)的jQuery方法一樣。
2:children方法獲得的僅僅是元素一下級(jí)的子元素,即:immediate children。
3:find方法獲得所有下級(jí)元素,即:descendants of these elements in the DOM tree
4:children方法的參數(shù)selector 是可選的(optionally),用來過濾子元素,但find方法的參數(shù)selector方法是必選的。
5:find方法事實(shí)上可以通過使用 jQuery( selector, context )來實(shí)現(xiàn):英語如是說:Selector context is implemented with the .find() method; therefore, $('li.item-ii').find('li') is equivalent to $('li', 'li.item-ii').

例如,有以下html元素:

使用:$('ul.level-2').children().css('border', '1px solid green'); 的效果是:

使用 $('ul.level-2').find('li').css('border', '1px solid green'); 的效果是:

相關(guān)文章

最新評(píng)論