javascript set all checkbox true

Posted by ExiaHuang on July 20, 2017

javascript set all checkbox true

1
2
3
4
5
6
var inputs = document.getElementsByTagName("input"); //or document.forms[0].elements;
for (var i = 0; i < inputs.length; i++) {
  if (inputs[i].type == "checkbox") {
    inputs[i].checked = true;
  }
}