OnChange没有在IE中解雇 [英] OnChange not firing in IE

查看:101
本文介绍了OnChange没有在IE中解雇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望为DIV中的表单元素的所有更改触发Onchange事件

I wish to fire a Onchange event for all the changes of Form elements within a DIV

这是片段

<html>
<body>

<div id="container">
    <input type="checkbox"/>
    <input type="checkbox"/>
    <input type="text"/>
    <input type="text"/>
</div>

<script>
di = document.getElementById("container");
di.onchange = function(a){
alert("On Change Called");
}

di.onclick = function(a){
 alert("On Click Called");
}

</script>

</body>
</html>

当焦点从任何表单元素丢失到新元素时,会触发该事件表格,当某些内容更新时(例如:输入框更新)

The event is fired, when a focus is lost from any of the form elements to a new element of the form, when some content is updated (eg: the input box is updated)

以上代码适用于所有浏览器但不适用于IE,任何方式都可以这是IE

The above code works fine for all browsers' but not for IE, any way to do this is IE

推荐答案

实际上,IE,特别是IE7 / 8不支持 onchange 活动非常好。我建议您使用 onclick 事件。

Actually, IE, especially IE7/8 doesn't support onchange event very well . I do recommend you use onclick event.

这篇关于OnChange没有在IE中解雇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆