toggle checkbox with javascript
问题 I want to uncheck a checkbox using javascript. I have one button which just unchecks the box and works fine: function clear() { document.getElementById("check").checked = ""; } I have another button that I want to check the box if not checked and uncheck if it is. Below doesn't uncheck the box. I can can switch the if statement and does works the opposite way. What's the problem? function switchIt() { if (document.getElementById("check").checked !== "checked") { document.getElementById("check