Latest web development tutorials

jQuery not () method

jQuery traversal methods jQuery traversal methods

Examples

Returns all <p> elements without a class name "intro" of:

$("p").not(".intro")

try it"

Definition and Usage

not () method returns the element does not meet certain conditions.

This method allows you to specify a condition. Ineligible elements from the select returned, eligible elements will be removed.

This method is usually used to remove one or more elements selected from the element combination.

Tip: not () method is filter () method relative.


grammar

$(selector).not( criteria, function (index) )

参数 描述
criteria 可选。规定要从被选元素组合中移除的选择器表达式、jQuery 对象、一个或多个元素。

提示:如需规定多个条件,请使用逗号分隔。
function( index ) 可选。为组合中的每个元素规定要运行的函数。如果返回 true,则移除元素,否则元素将被保留。
  • index- 集合中元素的 index 位置。
注意: this 是当前的 DOM 元素。

Examples

More examples

Returns are not all even-numbered <p> element
Use: even selectors and not () to return a <p> element is not all even-numbered.

Multiple conditions
How to return to class is not "intro" and id is not "outro" all <p> elements.

Use jQuery object
How to Return <div> element within the class is not "intro" all <p> elements via jQuery object.

DOM
How to return the DOM element id is not "intro" all <p> elements.

Using Functions
How to use the function to select that no two <span> element in all <p> elements therein.


jQuery traversal methods jQuery traversal methods