jQuery API 返回首页目录 | jQuery API 中英文对照版
find(expr)
find(expr)

搜索所有与指定表达式匹配的元素。这个函数是找出正在处理的元素的后代元素的好方法。

所有搜索都依靠jQuery表达式来完成。这个表达式可以使用CSS1-3的选择符语法或基本的XPath语法来写。

返回值:jQuery

参数:

  • expr (String): 用于搜索的表达式
 
示例:

从所有的段落开始,进一步搜索下面的span元素。与$("p span")相同。

$("p").find("span"); 

HTML 代码:

<p><span>Hello</span>, how are   you?</p>

结果:

[ <span>Hello</span> ] 
 
find( expr )

Searches for all elements that match the specified expression. This method is a good way to find additional descendant elements with which to process.

All searching is done using a jQuery expression. The expression can be written using CSS 1-3 Selector syntax, or basic XPath.

Return value: jQuery
Parameters:

  • expr (String): An expression to search with.
 

Example:

Starts with all paragraphs and searches for descendant span elements, same as $("p span")

 $("p").find("span");  
Before:
 <p><span>Hello</span>, how are you?</p>  
Result:
 [ <span>Hello</span> ]  
相关链接
asp之家 | jQuery官方网站 | jQuery中文网 | 电子书作者网站 | 电子书作者blog