+ 2
Javascript question: property
How to fix this error that appears when I use innerHTML or innerText in both of these. Uncaught TypeError: Cannot set property 'innerHTML' of null
13 Antworten
+ 1
Farhad Rahmani just wrapped it into
window.onload = () => {
// Your code should be here
}
+ 1
🎃#H P 22™🎃 I think. His code doesn't have any bug or error. But sololearn behaves differently from browser. When you use js tab. It is good practice to wrap your code in window.onload
+ 1
Farhad Rahmani Did my code works?
+ 1
Javascript loads line by line so when it hits the line with innerHTML it gives an error because it haven't gotten anything with that class or id so it's very simple to resolve it just add your script tag at the end of body tag
🙌Happy Coding 🙌
0
🎃#H P 22™🎃 what is wrong in syntax?
0
100 time i checked but that was perfectly correct.
0
Farhad Rahmani just wrap it into
window.onload = () => {
// Your code should be here
}
0
No i have coded in visual code but over here is also that kind of error.
0
0
Vivek no bro sorry because over there have to shown day hour minute and seconds.
0
See one more time.
do it works?
https://code.sololearn.com/WN3BKy9a17Rn/?ref=app