views:

41

answers:

1
<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

Thanks, Amit

+4  A: 

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.

Nick Craver