javascript - how to get the html tag's ID name from html tag's value? -
how html tag's id name content.
have following textboxes.
want find id value "a2"
means want result id=option2 because it's value = a2
<input type="text" name="option1" id="option1" value="a1"> <input type="text" name="option2" id="option2" value="a2"> <input type="text" name="option3" id="option3" value="a3"> <input type="text" name="option4" id="option4" value="a4">
you can try with:
var id = $('input[value="a2"]').attr('id');
output:
option2
Comments
Post a Comment