📜  js for i in html 集合 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:37.287000             🧑  作者: Mango

代码示例1
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
}