如何限制jQuery的搜索范围 [英] how to limit the jquery search scope
本文介绍了如何限制jQuery的搜索范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用选择器时,看起来JQuery
在当前document
中进行搜索.
It looks like JQuery
does the search in the current document
when using a selector.
如何仅在div
元素内搜索元素?
How to search for an element only inside a div
element?
推荐答案
jQuery选择器的工作方式与CSS选择器非常相似,您可能会更熟悉.
jQuery selectors work very much like CSS selectors, which you may be more familiar with.
首先,选择div,然后从中降级:
First, select the div, and then descend from that:
$('#my-div').find('some-selector').
或构建选择器以匹配相关元素的子元素:
or build your selector to match children of the element in question:
$('#my-div some-selector')
这篇关于如何限制jQuery的搜索范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文