Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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");
     });
 }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #queryselectorall #loop
ADD COMMENT
Topic
Name
3+5 =