Checkbox onchange事件在谷歌上ok,在ie8上不起作用了。

一番周折,测试发现勾选了以后还要点击其他位置才会触发onchange事件.

用度娘查询了一下.

有下面两种解决方式:

用onclick事件代替

1、<input type=checkbox onclick="alert(this.value)" value=huerreson>

用onpropertychange事件代替
2、<input type=checkbox onpropertychange="alert(this.value)" value=huerreson>

IE下,当一个HTML元素的属性改变的时候,都能通过 onpropertychange来捕获。

IE 6 / 7 / 8 下 checkbox 不会触发 onchange 事件,不管选中还是未选中。

所以你应该使用 onclick。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-24
  • 2021-12-16
  • 2021-11-10
  • 2021-12-06
  • 2021-05-26
猜你喜欢
  • 2021-10-23
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2021-06-26
  • 2022-12-23
  • 2021-12-24
相关资源
相似解决方案