Friday, 15 May 2015

javascript - How to find input with specific value -



javascript - How to find input with specific value -

requirement, want find input fields have been entered specific

html,

<ul class="test-list"> <li> <input class="test-input"> </li> <li> <input class="test-input"> </li> <li> <input class="test-input"> </li> </ul>

example,

if user entered "test1", "test2", "test3" in each input field

i tried javascript,

$('.test-list').find('.test-input [value="test1"]')

and expect getting input field have entered test1, returns 0 array :(

i tried filter() , witht works, want find straight first one.

test-input classname , not tagname. need remove space in name-value selector , .test-input. need use:

$('.test-list').find('.test-input[value="test1"]');

you can narrow downwards selector to:

$('.test-list [value=test1]');

working demo

javascript jquery

No comments:

Post a Comment