Check/uncheck checkbox with JavaScript
Jump directly into the action by manipulating a checkbox's checked attribute:
Translate true or false into a checked state to shift "the reality program" of your checkbox.
Working deep with checkboxes
Master more complex checkbox manipulations through diverse methods:
User simulation with click()
Simulate user interaction, by invoking the checkbox's click event:
Supporting Sir Old Browser
For those visiting from "the land of the lost browsers", use setAttribute & removeAttribute:
Riding the jQuery wave
In the world of jQuery, .prop() is your magic wand for state changes:
Time traveling to jQuery versions below 1.6:
Pro level tricks with checkboxes
User experience - A guiding light
Always make your checkmarks visible and accessible. Use proper aria attributes and provide visual confirmation of state changes. UI ninjas keep their users informed.
Being dynamic with addEventListener
Use addEventListener to ride the change wave every time the checkbox state changes.
Handling an army of checkboxes
In scenarios with multiple checkboxes (we're looking at you, email clients):
Was this article helpful?