js for i in html collection

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

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
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}