The Wayback Machine - https://web.archive.org/web/20240213201529/https://www.geeksforgeeks.org/jquery-attributevalue-selector-5/
Open In App
Related Articles

jQuery [attribute!=value] Selector

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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>
    <title>jQuery [attribute!=value] Selector</title>
    <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>
    <title>jQuery [attribute!=value] Selector</title>
    <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:

 


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Looking for a place to share your ideas, learn, and connect? Our Community portal is just the spot! Come join us and see what all the buzz is about!


Last Updated : 10 Jul, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials