Home  >  jQuery

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>
 
In the example the input string is xy. Now we have four input element. Only first and second is fulfilling the requirement.
Output
FIND MORE TUTORILAS






©2019 concretepage.com | Privacy Policy | Contact Us