Andrey Koltsov
Andrey Koltsov

Reputation: 1974

IE doesn't fire change event on select on enter and tab

I have a code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready( function() {
            $("#my_select").change(function(e){alert(e);})
            $("#my_select").focus();
        });
    </script>   
  </head>
  <body>
    <select id="my_select">
        <option>1</option>
        <option>2</option>
        <option>3</option>
    </select>
    <input />
  </body>
  </html>

open in IE, select will be in focus, select any number with up/down/letters keyboard buttons, and press enter/tab key no alert will be fired. WHY????

PS: yes jquery version is old, I know about it, but I can't switch to newer one now.
PS2: IE8 and IE6

Upvotes: 2

Views: 1709

Answers (1)

Jonathan Lonowski
Jonathan Lonowski

Reputation: 123493

It probably won't fire on blur (enter/tab) as it would've already fired on the arrow up or down -- which it does just that when trying it in IE9.

IE (also Opera) has been consistent in being "buggy" with handling the change event for <select> elements: http://www.quirksmode.org/dom/events/change.html#t05

Also note that issues between jQuery 1.4.2 and older versions of IE may be contributing to this, as a few bugs were reported for 1.4.2 and fixed in 1.4.3: #6374 and #6956.

Upvotes: 2

Related Questions