Choose window behavior 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>

Firefox alerts only once

In IE7 / 8, a warning appears twice. Just wondering why in IE warning comes twice

Thanks Amit

+3
source share
1 answer

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

Currently (only in IE), the DOM 0 event handler (your built-in) is launched onchange, and then the jQuery handler ... something about this execution forces the DOM 0 handler to start again.

+4

Source: https://habr.com/ru/post/1768404/


All Articles