jquery的find的filter的区别


filter will select a certain subset (zero or more) of the already
selected elements.
jquery的filter将在一组已经选取的元素里面选择
find will select a set of (zero or more) elements that are descendants
of the already selected elements.
jquery的find将在一组已经选取的元素的子节点里面选择

Here is an example:
示例如下

<div class="peanuts"> 
        <p class="elephants"></p> 
</div> 
<div class="elephants"> 
        <p></p> 
</div> 

$(‘div’).filter(‘.elephants’); // <-- selects the second div, because it has class="elephants" $('div').find('.elephants'); // <-- selects the first paragraph, because it has class="elephants" * Note that these two examples are very simple and would probably be better written as ... $('div.elephants'); ... and ... $('div .elephants');


发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据