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