<select id="myselect">
<option value="10">Mr</option>
<option value="20">Mrs</option>
<option value="30">Ms</option>
<option value="40" selected>Dr</option>
<option value="50">Prof</option>
</select>
I need to get the order of selected option which is 4 if initial value is 1.
Try to use .index()
function to trace its order,
$("#myselect option:selected").index() + 1
// index() will return a 0 based index so added a 1 to it.
您可以使用.index()
$('option').index(':selected'); //will return 3 as index is 0 based property
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.