document.getElementById returns null | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

document.getElementById returns null

im not quite sure but I think my problem is that the js file is added in the head element and not on the bottom of the page so the objects I'm trying to get are still not *loaded* but that's just my guess any help how I can fix that is appreciated! thanks in advance! (I'm new to sololearn)

19th Feb 2018, 5:11 PM
Niko Harpson
Niko Harpson - avatar
1 ответ
+ 8
In fact, in CodePlayground the scripts load inside the head of the page. The most common solution to your problem is to move the code inside the "window.onload" event, that way it will only run when the page has loaded
19th Feb 2018, 5:26 PM
Mickel - avatar