Home >>jQuery Tutorial >jQuery :not() Selector

jQuery :not() Selector

jQuery :not() Selector

jQuery :not() selector in jQuery is used to selects all elements except the specified element.

Syntax:
$(":not(selector)")

Parameter Values

Parameter Description
selector It is a Required parameter and used to specifies the element to not select.
Here is an Example of jQuery :not() Selector

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p:not(.txt)").css("background-color", "Orange");
});
</script>
</head>
<body>
<h1>Welcome to Phptpoint</h1>
<p class="txt">My name is Phptpoint</p>
<p>I live in Noida.</p>
<p>Who is your favourite:</p>
<ul id="choose">
<li>JAVA</li>
<li>jquery</li>
<li>Javascript</li>
</ul>
</body>
</html>

Output:

Welcome to Phptpoint

My name is Phptpoint

I live in Noida.

Who is your favourite:

  • JAVA
  • jquery
  • Javascript

No Sidebar ads