jQuery filter () method
Definition and Usage
filter () method returns the elements meet certain conditions.
This method allows you to specify a condition. Ineligible elements removed from the selection, qualifying element will be returned.
This method is usually used to narrow the search in the selected element is a combination of elements in the range.
Tip: filter () method is not () method relative.
grammar
参数 | 描述 |
---|---|
criteria | 可选。规定要从被选元素组合中返回的选择器表达式、jQuery 对象、一个或多个元素。 提示:如需规定多个条件,请使用逗号分隔。 |
function( index ) |
可选。为集合中的每个元素规定要运行的函数。如果返回 true,则保留元素,否则元素将被移除。
|
More examples
Back to all even-numbered <p> element
Use: even select and filter () to return a <p> element in all even-numbered.
Multiple conditions
How to return to class as "intro" and id is "outro" all <p> elements.
Use jQuery object
How to Return <div> element within the class of "intro" all <p> elements via jQuery object.
DOM
How to return the DOM element with id "intro" of a <p> element.
Using Functions
How to select the function has two <span> element in all <p> elements therein.