【问题标题】:How to apply this code to work in ie browser (in ie not working)?如何应用此代码在 ie 浏览器中工作(在 ie 中不工作)?
【发布时间】:2014-05-26 16:22:50
【问题描述】:

如果用户选中了复选框unlimited_time,那么复选框not_allow_time和复选框unlimited_time将不会被选中

我已经在很多浏览器上测试过,它可以正常工作,但它不能在 Internet Explorer 上工作。

在ie上工作怎么办?

<input type="text" id="time" name="time"> 
<label style=" font-weight: normal;">
<input type="checkbox" id="unlimited_time" name="unlimited_time" value="Unlimited" class="checkme_time"/> Time UP
</label>
<label style=" font-weight: normal;">
<input type="checkbox" id="not_allow_time" name="not_allow_time" value="Not_allow" class="checkme_time"/> Not Guarantee
</label>
<script type="text/javascript">
document.getElementById('unlimited_time').onchange = function () {
    document.getElementById('not_allow_time').checked = false;
    document.getElementById('time').disabled = this.checked;
};
document.getElementById('not_allow_time').onchange = function () {
    document.getElementById('unlimited_time').checked = false;
    document.getElementById('time').disabled = this.checked;

};
</script>

【问题讨论】:

  • "在 ie 浏览器中" ?哪个版本?
  • 什么是unit_time?
  • The code in a jsFiddle 在最新的 Chrome 和 IE 10 中的工作方式相同。是否有特定的 IE 版本?
  • IE 调试器工具。开始调试。你会得到一些错误。分享它。可能会有帮助。
  • unit_time在哪里?尝试将.onchange 更改为.onclick。让我们看看它是否有效。

标签: javascript jquery html css internet-explorer


【解决方案1】:

.onchange 更改为.onclick

更多详情IE8 & IE7 onchange event is not getting triggered.

【讨论】:

    【解决方案2】:

    将我的 cmets 转换为答案

    1. 什么是 unit_time - IE 通常会在第一个错误时停止执行。如果你没有任何名为 id="unit_time" 的东西,你需要注释掉每个函数中的最后一行

    2. onchange 更改为 onclick,因为某些 IE 在复选框模糊之前不会触发 onchange

    Quirks mode onchange table for checkboxes

    【讨论】:

      猜你喜欢
      • 2015-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-18
      • 1970-01-01
      • 2016-12-30
      • 1970-01-01
      相关资源
      最近更新 更多