mardi 30 juillet 2019

Foreach function that clicks on check boxes

I need function to click on a range of check boxes. I do however not always know what i is. I tried a write a forEach loop, but it does not work:

This for loop works:

function check Boxes() {
  for (let i = 0; i < 249; i++) {
    document.getElementsByClassName("inventoryCbox")[i].click();

  }
}

and this is the non-working for loop. I think that maybe my syntax is wrong.

checkBoxes();
var boxes = document.getElementsByClassName("inventoryCbox");

function checkBoxes(node) {
  node.forEach(function(boxes) {
    boxes.click()
  });
}




Aucun commentaire:

Enregistrer un commentaire