How can I check if a checkbox is checked via jQuery?
Can I just add an ID or class to the element and do this?
if($('#element').val() == 1) {
//do stuff
}
if($('#element').is(':checked')){
//checkbox is checked
}
or
if($('#element:checked').length > 0){
//checkbox is checked
}
or in jQuery 1.6+:
if($('#element:checked').prop('checked') === true){
//checkbox is checked
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With