How can I check if a checkbox is checked?

前端 未结 14 1116
轮回少年
轮回少年 2020-11-22 14:28

I am building a mobile web app with jQuery Mobile and I want to check if a checkbox is checked. Here is my code.



        
相关标签:
14条回答
  • 2020-11-22 14:55

    use like this

    <script type=text/javascript>
    function validate(){
    if (document.getElementById('remember').checked){
              alert("checked") ;
    }else{
    alert("You didn't check it! Let me check it for you.")
    }
    }
    </script>
    
    <input id="remember" name="remember" type="checkbox" onclick="validate()" />
    
    0 讨论(0)
  • 2020-11-22 14:57
        if (document.getElementById('remember').checked) {
            alert("checked");
        }
        else {
            alert("You didn't check it! Let me check it for you.");
        }
    
    0 讨论(0)
提交回复
热议问题