The checkbox checked property of a checkbox element gives you the checked state of the element. But you can also check using is() method.
<input type="checkbox" id="checkID"/>
Then using checked property you can check this:
if(document.getElementById('checkID').checked){
// checked
} else {
// unchecked
} Alternatively, you can use jQuery is() function as below:
if($("#checkID").is(':checked')){
// checked
} else {
// unchecked
} Using attr or prop method you can check the status:
$('#checkID').attr('checked'); // "checked"
$('#checkID').prop('checked'); // true You can use bind to change event instead of. You will probably still need to check whether or not the checkbox is checked:
$("#checkID").change(function() {
if(this.checked) {
//Do stuff
}
}); Read jQuery tips and tricks for more topics.
Motorcycle accidents often lead to severe injuries because riders have minimal protection compared to drivers…
No business owner starts his or her business with the hope of making losses. Everyone…
Car accidents can be traumatic, and the physical and psychological aftermath of a car accident…
Worker's compensation insurance deals with all those employees that get work-related injury or illness. When…
Mobile commerce is no longer a trend. It is the main stage where buyers make…
The field of education welcomes and recognizes AI's potential to provide a more immersive learning…