jquery onchange checkbox code example
Example 1: jQuery checkbox changed event
$("#myCheckBoxID").change(function() {
if(this.checked) {
}else{
}
});
Example 2: jquery onchange input value
$("input").change(function(){
alert("The text has been changed.");
});
Example 3: change checkbox jquery alert
$(document).ready(function() {
$('#textbox1').val(this.checked);
$('#checkbox1').change(function() {
if(this.checked) {
var returnVal = confirm("Are you sure?");
$(this).prop("checked", returnVal);
}
$('#textbox1').val(this.checked);
});
});
Example 4: change checkbox jquery alert
$(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'));
});
});