How to Fill a Checkbox in JavaScript?

Estimated read time 1 min read

In HTML, a checkbox is an input element with a type attribute set to checkbox. To fill a checkbox in JavaScript, you can use the checked property of the checkbox element:

const checkbox = document.getElementById("myCheckbox");
checkbox.checked = true;

This will fill the checkbox, causing it to appear as selected or checked. You can also set the checked property to false to uncheck the box.

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply