I need to select elements depending on first letter of text value of a tag.
For example:
<li><label for="1"><input type="checkbox" name="contacts" value="1">Aaron</label></li>
<li><label for="2"><input type="checkbox" name="contacts" value="2">Born</label></li>
<li><label for="3"><input type="checkbox" name="contacts" value="3">Bale</label></li>
<li><label for="4"><input type="checkbox" name="contacts" value="4">Kate</label></li>
And I want to select all inputs that text value starts with B – in result it should be Born and Bale inputs. How can I do this using jQuery/pure javascript?
Try this: http://jsfiddle.net/bb2uE/
Html:
Javascript:
Or, if you want to hide those inputs: http://jsfiddle.net/bb2uE/1/
Javascript: