0
Uncaught TypeError: Cannot set properties of null
Hi thanks for helping , when i create an element inside the html body , and i give it an id , like <p id="age"></p> and in Js when i want to set innerHTML for that element , it gives me Uncaught TypeError: Cannot set properties of null, even when i gave it id but still giving same problem , i have other code that doesnt have this problem , i don't know why this happen ? Note: i create elements inside <body></body> tags , here on soloLearn . But gives this error , while i have other code and done same thing here on SoloLearn and no problem it works , but now no matter i create any new web code and i want to id and element js see it as null , any one please have a solution for this ? Thanks https://code.sololearn.com/WFqpBh0Xuenx/?ref=app
2 Respuestas
+ 2
This is due to the fact that the JavaScript file is loaded before the html document.
Use the boot delay feature:
onload=()=>{
document.getElementById...
...
}
+ 1
Thanks alot man, i'm a noob still 😅i'm at the very beginning of this , hopefuly i learnt something new from you thank you very much 👍👍👍✌