0

Why this JavaScript code doesn't work

I think i do the correct way, but what wrong on my code https://code.sololearn.com/WPkIw8WMTmra/?ref=app

6th Sep 2021, 7:41 AM
EsaKurniawan
2 Réponses
+ 3
EsaKurniawan Because className returns node list. Since there is only one element with that class so it should be like this: document.getElementsByClassName("whatever")[0].innerHTML = "Why it's doesn't work"; But don't forget to write js code inside this function: window.onload = function () { } ------ window.onload = function () { document.getElementsByClassName("whatever")[0].innerHTML = "Why it's doesn't work"; }
6th Sep 2021, 7:44 AM
A͢J
A͢J - avatar
6th Sep 2021, 7:59 AM
EsaKurniawan