FormsLesson 140Free preview
Check Checkbox
This lesson is part of How To · All levels
Summary
Checkboxes are a pattern for displaying or hiding content based on the status of the checkbox. JavaScript reads the checked property and changes the look of other elements, such as an additional column or a newly activated button. Event change is used to handle changes immediately when a user checks or removes a cheque.
Key points
- The property is worth either checkbox.checked or false.
- Event change is triggered when the status of the checkbox changes.
- ClassList.toggle or hidden properties can display and hide elements.
- For many checkboxes, use querySelectorAll and filter checks.
- Connect the checkbox to the label and group it to the fieldset if relevant.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.