jQuery [attribute!=value] Selector

jQueryWeb DevelopmentFront End Technology

The [attribute!=value] selector in jQuery is used to select each element that isn’t having the specified attribute and value.

Syntax

The syntax is as follows −

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

Example

Let us now see an example to implement the jQuery [attribute!=value] selector −

<!DOCTYPE html>
<html>
<head>
<style>
   .one {
      color: white;
      background-color: orange;
      font-size: 16px;
      border: 2px blue dashed;
   }
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
   $(document).ready(function(){
      $("p[class!='demo']").addClass("one");
   });
</script>
</head>
<body>
<h1>Car Details</h1>
<p>Car is XUV500</p>
<p class="demo">2179 cc</p>
<p>Independent Suspension</p>
<p>Fuel Tank Capacity: 70 litres</p>
</body>
</html>

Output

This will produce the following output −

raja
Published on 11-Nov-2019 11:46:39
Advertisements