js checkbox event code example
Example 1: javascript event listener checkbox
var checkbox = document.querySelector("input[name=checkbox]");
checkbox.addEventListener( 'change', function() {
if(this.checked) {
} else {
}
});
$('input[name=checkbox]').change(function(){
if($(this).is(':checked')) {
} else {
}
});
Example 2: oncheck checkbox javascript
<input type='checkbox' onchange='handleChange(this);'> Checkbox
function handleChange(checkbox) {
if(checkbox.checked == true){
document.getElementById("submit").removeAttribute("disabled");
}else{
document.getElementById("submit").setAttribute("disabled", "disabled");
}
}