0

why we are have error

for(var i=0;i<100;i++){ var cell = document.createElement("div") cell.classList.add("cell") document.getElementsByClassName("board").appendChild(cell) } errooooooor: Uncaught TypeError: document.getElementsByClassName(...).appendChild is not a function

23rd Oct 2022, 11:18 AM
pouya iranzad
pouya iranzad - avatar
1 Réponse
+ 1
document.getElementsByClassName("board") is returns an array, not a single item, if "board" Class exists. So you can't apply appendChild to array of elements directly..
23rd Oct 2022, 11:52 AM
Jayakrishna 🇼🇳