Open In App

jQuery [attribute$=value] Selector

Improve
Improve
Like Article
Like
Save
Share
Report

The jQuery [attribute$=value] selector is used to select each element with a specific attribute, with a specific ending string. 

Syntax: 

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

Parameter: 

  • attribute: This parameter is required to specify the attribute to find.
  • value: This parameter is required to specify the string i.e. the value should end with.

Example 1: 

HTML




<!DOCTYPE html>
<html>
 
<head>
    <script src=
    </script>
    <script>
        $(document).ready(function () {
            $("a[href$='.org']").css(
                "background-color", "green");
        });
    </script>
</head>
 
<body>
    <center>
        <h1>GeeksForGeeks</h1>
        <a href="https://www.geeksforgeeks.org/">
            geeksforgeeks.org
        </a>
        <br>
        <a href="http://www.google.com">
            Google.com
        </a>
        <br>
        <a href="http://www.wikipedia.org">
            wikipedia.org
        </a>
    </center>
</body>
 
</html>


Output: 

  

Example 2: 

HTML




<!DOCTYPE html>
<html>
 
<head>
    <script src=
    </script>
    <script>
        $(document).ready(function () {
            $("h3[id$='.org']").css(
                "background-color", "green");
        });
    </script>
</head>
 
<body>
    <center>
        <h1>GeeksForGeeks</h1>
        <h3 id="geeksforgeeks.org/">
            geeksforgeeks.org
        </h3>
        <h3 id="google.com">
            Google.com
        </h3>
        <h3 id="wikipedia.org">
            wikipedia.org
        </h3>
    </center>
</body>
 
</html>


Output:

 



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