const container = document.getElementById("container"); // console.log(container.children); let contents = Array.from(container.children); // console.log(images); contents.forEach((item) => { console.log(item); left = Math.random() * 100; top = Math.random() * 100; zIndex = Math.round(Math.random() * 1000); item.style.left = left + "%"; item.style.top = top + "%"; item.style.zIndex = zIndex; });