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.
Content marketing has a hidden tax. It's not the writing itself, it's everything that happens…
Most marketing teams aren't failing because they lack data. They're failing because they can't act…
Email marketing continues to be one of the most effective ways for businesses to communicate,…
Xerox first introduced it around the mid-1970s. The need came up because the management activities…
Investing in the forex market may look to be a dangerous game. With some worthwhile…
The coronavirus outbreak has drastically changed the way we live our lives. Yes, that's absolutely…