小编Got*_*teh的帖子

oncheck listener for javascript中的复选框

我的表单底部有这样的代码.

<p>
  <input type="checkbox" id="agreed">
  I agree to keep my Username and Password confidential and uphold 
  the integrity of this pharmacy
</p>
<input type="submit" id="submit" disabled class="formbutton button-primary" value="Go">
Run Code Online (Sandbox Code Playgroud)

我希望这个JavaScript中的监听器能够启用提交按钮.我知道它可能是错误的,但我的JavaScript看起来有点像这样

function track() {
    if ( document.getElementById("agreed").checked==true ) {
        document.getElementById("submit").removeAttribute("disabled");
    } else {
        document.getElementById("agreed").checked==false
    }
};
Run Code Online (Sandbox Code Playgroud)

html javascript dom

15
推荐指数
1
解决办法
5万
查看次数

标签 统计

dom ×1

html ×1

javascript ×1