checkbox选中之后 才能点击按钮

来源:互联网 发布:淘宝中差评扣分 编辑:程序博客网 时间:2024/06/12 05:33
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>注册</title>
    <script>
        function check(){
            var checkbox = document.getElementById("ch");//选中checkbox的id;
            if(checkbox.checked==true){//按钮已选中
                document.getElementById("but").style.backgroundColor="red";
                document.getElementById("but").removeAttribute("disabled");//移除disabled
            }else{
                document.getElementById("but").disadled="disabled";
            }
        }
    </script>
</head>
<body>
    <form name="form1" action="还是按钮.html">
        <input type="checkbox" id="ch" onclick="check()">我同意协议<br>
        <input type="submit" disabled="disabled" id="but" value="提交注册">
    </form>
</body>
</html>
0 0
原创粉丝点击