jQuery selected name -


if tom selected drop down box, how name , not value using jquery resulting output tom?

<select id="emp" >   <option value=1>tom</option>   <option value=12>harold</option>e    <option value=32>jenny</option> </select> 

var res = $('#emp :selected').text(); 

this gets element the id emp, gets the descendant element :selected, returns the .tex() content.

here's plain javascript version:

var el = document.getelementbyid('emp');  var res = el.options[el.selectedindex].text; 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -