Reputation: 2781
<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.
Upvotes: 0
Views: 850
Reputation: 82241
You can use .index()
$('option').index(':selected'); //will return 3 as index is 0 based property
Upvotes: 0
Reputation: 67207
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.
Upvotes: 1