How to check if checkbox is checked in JavaScript?

To check if checkbox is checked in JavaScript, do this: if (checkbox.checked).

For example, if this is your checkbox input:

<input type="checkbox" id="my-checkbox">
<label for="my-checkbox">Checked</label>

Then you can check if its checked with this JavaScript:

if (document.getElementById('my-checkbox').checked) {
  console.log('Checkbox is checked!');
} else {
  console.log('Checkbox is NOT checked!');
}