+ 1
In my project how do I fix the issue of console saying textContent cannot read?
Please refer to my Birthday Invitation Webpage project here on Sololearn and you will see on phone that when we press run the console says textContent cannot read which should not be a problem as it a function predefined in CSS.?? Why is this happening and how do I fix it? Pps help.
2 Réponses
+ 5
Use a event listener to run JavaScript when page loads
It is showing error because the JavaScript is running before the window render the html, that means at time of execution of JavaScript there is no html element so it can't read textContent of null
See the fixed code i have used an event listener to run the js when the page loads
https://code.sololearn.com/WjPa7Jqp8pf5/?ref=app
+ 1
Thank you