Home  >  jQuery

jQuery Attribute Contains Selector

February 25, 2013
jQuery provides different type of selector to select the elements from a HTML code. One of them is Contains Selector. Contains Selector means that jQuery searches specified element and match with given value. And then we can assign value at one go.
<script>$('input[name*="xy"]').val('CLICK');</script>
Give the element type and then name with * and then give the value of pattern matching and then assign a value. Get the full example.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<input type="button" name="xy"/>
<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