javascript - Can I get Select box value from given select box text -


can select box value given select box text ? need help

<select id='list'> <option value='1'>option a</option> <option value='2'>option b</option> <option value='3'>option c</option> </select>  $("#list[text='option b']").val(); 

you can use filter:

$("#list option").filter(function(){      return $(this).text().trim() == 'option b'; }).val(); 

you use $("#list option:contains(option b)"), bring multiple results in case.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -