jQuery Contains Word Selector
February 25, 2013
jQuery API provides the way that we can select a matching word in the attribute value. To identify that only match with word, it checks the space before the word is there should not be other character.
<!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="ab xy"/> <input type="button" name="axybd"/> <input type="button" name="abxcy"/> <script>$('input[name~="xy"]').val('CLICK');</script> </body> </html>
Output