Selecting and Unselecting All Checkboxes in JavaScript with a Button #webdevelopment #javascripttutorial #html5

Posted by

Select/Unselect all Checkbox using JavaScript

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;
}
}

0 0 votes
Article Rating

Leave a Reply

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x