Hello guys,
If you want to check and unchecked the checkbox in javascript and jquery use the below code.
For example :
Checkbox: <input type="checkbox" id="checkboxid" class ='checkboxclass'>
Checked and unchecked to checkbox in javascript :
document.getElementById("checkboxid").checked = true;
document.getElementById("myCheck").checked = false;
Checked and unchecked to checkbox in JQuery :
jQuery 1.6+
Best way for checked and unchecked by "prop" function in this version.
$('.checkboxclass').prop('checked', true);
$('.checkboxclass').prop('checked', false);
jQuery 1.5.x and below
Best way for checked and unchecked by "attr" function in this version.
$('.checkboxclass').attr('checked', true);
$('.checkboxclass').attr('checked', false);
Remove checked from checkbox :
$('.checkboxclass').removeAttr('checked');
0 Comment(s)