Checkbox checked JavaScript | HTML example code

How to check checkbox is checked or not in JavaScript?

A checked is Boolean property so you can directly use it in IF condition, whether a checkbox checked or not.

Example of checkbox checked JavaScript

Here is Html example code to Display Text when Checkbox is Checked or not checked on clicking the button.

Output:

Checkbox checked JavaScript

Note: Your script doesn’t know what the variable remember is if it placed after the script code. You need to get the element first using getElementById().

if checkbox is checked value=1 else 0 JavaScript

No JavaScript required, just put a hidden input before the checkbox:

Do comment if you have any questions or suggestions on topic.

Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.