handling checkbox checked and unchecked in javasceript code example

Example 1: javascript check uncheck checkbox

document.getElementById("myCheckBoxID").checked = true; // Check
document.getElementById("myCheckBoxID").checked = false;// Uncheck

Example 2: fill checkbox javascript

// Check
document.getElementById("checkbox").checked = true;

// Uncheck
document.getElementById("checkbox").checked = false;

Example 3: checked unchecked through js

document.getElementById("checkbox_id").checked;
//If checked returns true;
//else returns false;

Tags: