0
code 001 Unable to fix the error
4 odpowiedzi
+ 1
Uncaught TypeError: Cannot set properties of null (setting 'textContent') Line: 10
Error means : you can't set any property (textContent) of null data type.
The value of variable element is null because javascript code is executing first, followed by html part get executed.
Solution:
Place javascript code along html using script tags.
Correct code:
https://code.sololearn.com/WQqMddMY8GOD/?ref=app
+ 1
.A.D. Is it possible to keep this js code outside the html file ?
0
I want to keep js file seperately then how can we do in this example ?
0
Yes,
This can be done by wrapping the js code in a function.
And call that function from html part (using script tags).
https://code.sololearn.com/WQqMddMY8GOD/?ref=app