[attribute$=value] selector selects each element whose attribute ends with a string. - Javascript jQuery Selector

Javascript examples for jQuery Selector:attribute ends with

Description

The [attribute$=value] selector selects each element whose attribute ends with a string.

Syntax

Parameter Description
attribute Required. attribute to find
value Required. string ending

The following code shows how to select all <a> elements with a href attribute that ends with ".org":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("a[href$='.org']").css("background-color", "blue");});
</script>//w  ww  . j a  v  a  2s  . c o m
</head>
<body>

<a href="http://www.java2s.com">java2s.com</a><br>
<a href="http://www.google.com">Google.com</a><br>
<a href="http://www.wikipedia.org">wikipedia.org</a>

</body>
</html>

Related Tutorials