JS Coding Questions Logo
JS Coding Questions
#334💼 Interview💻 Code

How do you get the status of a checkbox

Advertisement

728x90

You can apply the checked property on the selected checkbox in the DOM. If the value is true it means the checkbox is checked, otherwise it is unchecked. For example, the below HTML checkbox element can be access using javascript as below:

html
1<input type="checkbox" id="checkboxname" value="Agree" />
2
3Agree the conditions
4<br />
javascript
1console.log(document.getElementById(‘checkboxname’).checked); // true or false

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 77

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
334of476