Problem with onMouseOut event with select box options (IE)

Issue

The problem I am facing with below code is that whenever I try to select any option from the select box, the mouseout event executed (in IE, Mozilla doing great) and option disappear. How can one get over this bug?

<select name="ed" id="ed" dir="ltr"  style="width:200px;overflow:hidden;" onMouseOver="this.style.width='auto'" onMouseOut="this.style.width='200px';">
      <option value="1" selected="selected">click here</option>
      <option value="1">Samuel Jackson</option>
      <option value="2">David Nalog</option>
      <option value="3">This one is a real real big name</option>
 </select>

Solution

I changed the code do it conditionally. Now it is working fine. Check it.

<select name="ed" id="ed" dir="ltr"  style="width:200px;overflow:hidden;" 
        OnMouseOver="this.style.width='auto';" onmouseout="if(!this.focussed) {this.style.width='200px';}"  onfocus="this.focussed=true;" onblur="this.style.width='200px';this.focussed=false;" >
      <option value="1" selected="selected">click here</option>
      <option value="1">Samuel Jackson</option>
      <option value="2">David Nalog</option>
      <option value="3">This one is a real real big name</option>
     </select>

Answered By – dotcoder

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published