Select/Unselect all Checkbox using JavaScript
Select All
Option 1
Option 2
Option 3
Option 4
function selectAllCheckboxes() {
var checkboxes = document.getElementsByClassName(“checkbox”);
var selectAllCheckbox = document.getElementById(“selectAll”);
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].checked = selectAllCheckbox.checked;
}
}
function unselectAllCheckboxes() {
var checkboxes = document.getElementsByClassName("checkbox");
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].checked = false;
}
}