jquery not() method


  Translation results:

not

UK[nɒt] US[nɑ:t]

adv.No; [used to express negation, denial, rejection, prohibition, etc.] No ;Hardly; Not necessarily, no [used to negate the following word or phrase]

jquery not() methodsyntax

Function: not() Remove elements from the set of matching elements.

Syntax 1: .not(selector)

Parameters:

ParameterDescription
selector String value, containing the selector expression used to match elements.

Syntax 2: .not(element)

Parameters:

ParametersDescription
element One or more DOM elements that need to be removed from the matching set.

Syntax 3: .not(function(index))

Parameters:

ParametersDescription
function(index) Used to detect the index of each element in the collection function. this is the current DOM element.

Note: If a jQuery object representing a collection of DOM elements is given, the .not() method will construct a new one with a subset of matching elements. jQuery object. The applied selector examines each element; elements that do not match the selector are included in the result.

jquery not() methodexample

<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js></script>
</head>
<body>
<p>This is a paragragh.</p>
<p>This is a paragragh.</p>
<p>This is a paragragh.</p>
<p id="selected">This is a paragragh.</p>
<p>This is a paragragh.</p>
<p>This is a paragragh.</p>
<script>
$("p").not("#selected").css('background-color', 'red');
</script>
</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance

Popular Recommendations

Home

Videos

Q&A