js for i in html collection

Solutions on MaxInterview for js for i in html collection by the best coders in the world

showing results for - "js for i in html collection"
Oskar
28 Sep 2019
1var list = document.getElementsByClassName("events");
2for (let item of list) {
3    console.log(item.id);
4}
5
6
7// To include older browsers (including things like IE), this will work everywhere:
8var list= document.getElementsByClassName("events");
9for (var i = 0; i < list.length; i++) {
10    console.log(list[i].id); //second console output
11}