function piliang() {
var ids = "";
var num = document.getElementsByName("check");
for (var i = 0; 1 < num.length; i++) {
if (num.item(i).checked) {
ids = ids + num.item(i).value + ",";
}
alert(ids);
}
run successfully
function piliang() {
var ids = "";
var num = document.getElementsByName("check");
for (var i = 0; 1 < num.length; i++) {
if (num.item(i).checked) {
ids = ids + num.item(i).value + ",";
}
}
This gives out the following error:
"Cannot read property 'checked' of null"
The first code also has this error, but it can run successfully
My English is not good, please try to explain it in code, thank you very much
console.log(num.item(i).checked)