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
Post a Comment