jQuery API | 返回首页目录 | jQuery API 中英文对照版 |
find(expr) |
find(expr)
搜索所有与指定表达式匹配的元素。这个函数是找出正在处理的元素的后代元素的好方法。 所有搜索都依靠jQuery表达式来完成。这个表达式可以使用CSS1-3的选择符语法或基本的XPath语法来写。 返回值:jQuery 参数:
从所有的段落开始,进一步搜索下面的span元素。与$("p span")相同。 $("p").find("span"); HTML 代码: <p><span>Hello</span>, how are you?</p> 结果: [ <span>Hello</span> ] 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
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> ] |