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>
<!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