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 with a specific attribute, with a value ending in a specific string.

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 string the value should end with
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(){
$("a[href$='.org']").css("background-color", "#4796d6");});
</script>
</head>
<body>
<a href="https://www.phptpoint.com">phptpoint.com</a><br>
<a href="http://www.google.com">Google.com</a><br>
<a href="http://www.wikipedia.org">wikipedia.org</a>
</body>
</html>

Output:
phptpoint.com
Google.com
wikipedia.org