Skip to content
Related Articles

Related Articles

jQuery [attribute!=value] Selector

Improve Article
Save Article
  • Last Updated : 16 Nov, 2022
Improve Article
Save Article

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

Syntax: 

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

Parameter: 

  • attribute: This parameter is required to specify the attribute to be searched.
  • value: This parameter is required to specify the value to be searched.

Example 1: 

HTML




<!DOCTYPE html>
<html>
<head>
  <script src=
  </script>
  <script>
    $(document).ready(function () {
      $("p[class!='intro']").css(
        "background-color", "green");
    });
  </script>
</head>
<body>
  <center>
    <h1>Welcome to GeeksForGeeks
    </h1>
    <p class="intro">Geeks</p>
    <p>For</p>
    <p>GEEKS</p>
    <p></p>
    Who is your favourite:
    <ul id="choose">
      <li>Geeks1</li>
      <li>Geeks2</li>
      <li>Geeks3</li>
    </ul>
  </center>
</body>
</html>

Output:

  

Example 2: 

HTML




<!DOCTYPE html>
<html>
<head>
  <script src=
  </script>
  <script>
    $(document).ready(function () {
      $("p[class='intro']").css(
        "background-color", "green");
    });
  </script>
</head>
<body>
  <center>
    <h1>Welcome to GeeksForGeeks
    </h1>
    <p class="intro">Geeks</p>
    <p>For</p>
    <p>GEEKS</p>
    <p></p>
    Who is your favourite:
    <ul id="choose">
      <li>Geeks1</li>
      <li>Geeks2</li>
      <li>Geeks3</li>
    </ul>
  </center>
</body>
</html>

Output:

 


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!