checkbox change event code example
Example 1: jQuery checkbox changed event
$("#myCheckBoxID").change(function() {
if(this.checked) {
}else{
}
});
Example 2: events on checkbox in jquery
$(document).ready(function() {
$('#textbox1').val($(this).is(':checked'));
$('#checkbox1').change(function() {
if($(this).is(":checked")) {
var returnVal = confirm("Are you sure?");
$(this).attr("checked", returnVal);
}
$('#textbox1').val($(this).is(':checked'));
});
});
Example 3: oncheck event jquery
$(".checkbox").change(function() {
if(this.checked) {
}
});
Example 4: checkbox click event jquery
$('input[type="checkbox"]').click(function(){
if($(this).is(":checked")){
$("#isClicked").val("Yes");
}
else if($(this).is(":not(:checked)")){
$("#isClicked").val("");
}
});
Example 5: checkbox change event javascript
document.getElementById('one').addEventListener('click', function(){
var two = document.getElementById('two');
two.checked = ! two.checked;
two.dispatchEvent('change');
});