onchange / onclick复选框在IE中不起作用 [英] onchange / onclick in a checkbox doesn't work in IE

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

问题描述

  chkbx_send_demo.onchange = function(){
if(sel_template.selectedIndex< = 0&&chkbx_send_demo.checked == true){
alert(Choose a Template);
sel_template.selectedIndex = 1;
}
if(chkbx_send_demo.checked == false){
sel_template.selectedIndex = 0;
}
}

但它在IE中不起作用。我试图将事件更改为chkbx_send_demo.onclick,但仍然无效。

解决方案

Internet Explorer只会触发onchange事件当复选框失去焦点时(onblur)。
也在这里看到:

http://krijnhoetmer.nl/stuff/javascript/ checkbox-onchange /

和here:

http://bytes.com/topic/javascript/answers/92116-onchange-checkbox


I have the following code, which works perfectly in Chrome/FF:

chkbx_send_demo.onchange = function(){
    if(sel_template.selectedIndex <= 0 && chkbx_send_demo.checked == true){
        alert("Choose a Template");
        sel_template.selectedIndex = 1;
    }
    if(chkbx_send_demo.checked == false){
        sel_template.selectedIndex = 0;
     }
}

But it just won't work in IE. I've tried to change the event to chkbx_send_demo.onclick and it still won't work.

解决方案

Internet Explorer only fires the onchange event when the checkbox loses the focus (onblur). also see here:
http://krijnhoetmer.nl/stuff/javascript/checkbox-onchange/
and here:
http://bytes.com/topic/javascript/answers/92116-onchange-checkbox

这篇关于onchange / onclick复选框在IE中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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