Amit Singh
Amit Singh

Reputation: 1746

Select box behaviour in IE

<title>Sample</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="jquery-1.4.2.min.js">
    </script>
</head>
<body>
<select onchange="alert('hi')">
    <option value="0" selected="selected">Option1</option>
    <option value="1">Option1</option>
    <option value="2">Option1</option>
</select>

<script>
    
    
    $('select').bind('change',function(){
    var a ="true";
    })



</script>

In Firefox alert is getting called only once.

In IE7/8 alert is coming twice. Just wondering why in IE alert is coming twice?

Upvotes: 3

Views: 263

Answers (1)

Nick Craver
Nick Craver

Reputation: 630379

It's not you, it's a jQuery bug with IE, filed in the bug tracker here, here and here....unfortunately it looks like it'll be jQuery 1.5 before they make a change fixing this.

Currently (only in IE) the DOM 0 event handler is triggered (your inline onchange) then the jQuery handler...then something about that execution causes the DOM 0 handler to fire again.

Upvotes: 4

Related Questions