简体   繁体   English

Mozilla Firefox中的javascript错误

[英]javascript error in Mozilla Firefox

Hello I'm using following code for checkbox to close some type of time picker, the code works fine in chrome but not works in Mozilla Firefox. 您好,我正在使用下面的复选框代码来关闭某种类型的时间选择器,该代码在chrome中工作正常,但在Mozilla Firefox中不起作用。 While running on Mozilla Firefox we got the following error, please suggest me some alternative so that it works in both browsers. 在Mozilla Firefox上运行时,出现以下错误,请为我建议一些替代方法,以便它在两种浏览器中均可使用。

Error: closeMonday is not defined 错误:未定义closeMonday

and the code is: 代码是:

<div class="checkbox" name="closeMonday" style="height:16px;float:left;margin-left:0;margin-top:0;margin-right:5px;display:block" onclick="onClickChangeValue(closeMonday.checked);">

Simply change the onclick to: 只需将onclick更改为:

onclick="onClickChangeValue(this.checked);"

The word this is reserved in JavaScript to describe the "current" element for example in click events, the element being clicked, so this is what you should use. 在JavaScript中, this保留这个词来描述“当前”元素,例如在单击事件中,该元素被单击,因此应使用此元素。

Chrome is probably "smart" enough to search the document for real element with such name or ID but you should not count on such behavior. Chrome可能足够“聪明”,可以在文档中搜索具有这种名称或ID的真实元素,但您不应指望这种行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM