Yash Saraiya Yash Saraiya - 2 months ago 7
HTML Question

Set the selected option as the first option in the selectbox

Open this link in IE to exactly understand the behavior that I will be describing and seek a hack for.

I have the following select list:

<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>

When I render this in IE, drop-down behavior of this changes compared to other browsers due to which some of the options are pushed above the selectbox while the others are pushed below (based on the selected option)

Since this is the default behavior of IE, what I am looking for is that the options should get re-ordered i.e. the option that a user selects should be made the first option. Check the image below:

enter image description here

Does anyone have a work-around for this ?

Also if anyone knows a hack to alter this default IE behavior, it would be great to know and learn that


Here is a method that works in Jquery:


<select id = "choose">
    <option value="null" name="volvo">Volvo</option>
    <option value="1" name="saab">Saab</option>
    <option value="2" name="mercedes">Mercedes</option>
    <option value="3" name="audi">Audi</option>


var choose = $("#choose").bind('change',function(){