listen for checkbox change javascript 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: checkbox event listener
checkbox = document.getElementById('conducted');
checkbox.addEventListener('change', e => {
if(e.target.checked){
}
});
Example 3: checkbox change event javascript
document.getElementById('one').addEventListener('click', function(){
var two = document.getElementById('two');
two.checked = ! two.checked;
two.dispatchEvent('change');
});