Reputation: 2013
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. While running on Mozilla Firefox we got the following error, please suggest me some alternative so that it works in both browsers.
Error: closeMonday is not defined
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);">
Upvotes: 1
Views: 509
Reputation: 66398
Simply change the onclick to:
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.
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.
Upvotes: 3