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
If adopting the top answer for jquery, remember that the object passed to the click function is an EventHandler, not the original checkbox object. Therefore code shoudl be modified as follows.
Html
Toggle All
Bar 1
Bar 2
Bar 3
Bar 4
Javascript
$(function() {
jQuery("[name=selectThemAll]").click(function(source) {
checkboxes = jQuery("[name=foo]");
for(var i in checkboxes){
checkboxes[i].checked = source.target.checked;
}
});
})