Answers for "js for i in html collection"

0

js for i in html collection

var list = document.getElementsByClassName("events");
for (let item of list) {
    console.log(item.id);
}


// To include older browsers (including things like IE), this will work everywhere:
var list= document.getElementsByClassName("events");
for (var i = 0; i < list.length; i++) {
    console.log(list[i].id); //second console output
}
Posted by: Guest on July-08-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language