Home >>jQuery Tutorial >jQuery [attribute!=value] Selector

jQuery [attribute!=value] Selector

jQuery [attribute!=value] Selector

jQuery [attribute!=value] selector in jQuery is used to selects each element that does NOT have the specified value and attribute, but with a different value, will be selected.

Syntax:
$("[attribute!='value']")

Parameter Values

Parameter Description
attribute It is a Required parameter and used to specifies the attribute to find
value It is a Required parameter and used to specifies the value to find
Here is an Example of jQuery [attribute!=value] Selector:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p[class!='attr2']").css("background-color", "#4796d6");
});
</script>
</head>
<body>
<h1>Welcome to Phptpoint</h1>
<p class="attr2">My name is phptpoint</p>
<p>I live in Noida</p>
Who is your favourite:
<ul id="option">
<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