Home  >  jQuery

jQuery Attribute Ends With Selector

February 25, 2013
jQuery provides API to find all those element whose attribute is ending with a given selector. It does not match with word instead it only checks expression.
<input type="button" name="abxy"/>
 
In the this input type, attribute name has the value abxy. So if selector will be xy then this element will be chosen by jQuery API.
<script>$('input[name$="xy"]').val('CLICK');</script>
 
To checks ends with selector, $ sign is used i.e jquery ends with wildcard is $. Find the example below.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<input type="button" name="xyd"/>
<input type="button" name="abxy"/>
<input type="button" name="axybd"/>
<input type="button" name="abxcy"/>

<script>$('input[name$="xy"]').val('CLICK');</script>
</body>
</html>
 
Output
FIND MORE TUTORILAS






©2019 concretepage.com | Privacy Policy | Contact Us