Answers for "queryselectorall loop all found"

0

queryselectorall loop all found

const cbox = document.querySelectorAll(".box");

 for (let i = 0; i < cbox.length; i++) {
     cbox[i].addEventListener("click", function() {
       cbox[i].classList.toggle("red");
     });
 }
Posted by: Guest on January-22-2022

Browse Popular Code Answers by Language