I have an HTML page with multiple checkboxes.
I need one more checkbox by the name \"select all\". When I select this checkbox all checkboxes in the HTML page must b
I'm surprised no one mentioned document.querySelectorAll(). Pure JavaScript solution, works in IE9+.
function toggle(source) {
var checkboxes = document.querySelectorAll('input[type="checkbox"]');
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i] != source)
checkboxes[i].checked = source.checked;
}
}
Check all?
Bar 1
Bar 2
Bar 3
Bar 4