首页 > 代码库 > get the text value of a selected option.

get the text value of a selected option.

1 <select id="myselect">
2     <option value="1">Mr</option>
3     <option value="2">Mrs</option>
4     <option value="3">Ms</option>
5     <option value="4">Dr</option>
6     <option value="5">Prof</option>
7 </select>

1, get value:

$( "#myselect" ).val();
//=> 1

2, get (inner)text:

$( "#myselect option:selected" ).text();
// => "Mr"

ref: How do I get the text value of a selected option?