checkbox on checked code example

Example 1: oncheck event jquery

$(".checkbox").change(function() {
    if(this.checked) {
        //Do stuff
    }
});

Example 2: check if checkbox is checked javascript

<script type=text/javascript>
  function validate(){
    if (remember.checked == 1){
      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()" />

Example 3: html checkbox checked

<input type="checkbox" name="ok" value="ok">
<label for="ok">I agree</label>

Tags:

Html Example