Как исправить ошибку" Cannot set property 'value' of null "? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Как исправить ошибку" Cannot set property 'value' of null "?

<html> <body> <p id="getid"></p> <script> var user = document.getElementById('getid'); user.value = "Hello."; </script> </body> </html>

23rd Dec 2016, 11:01 AM
ernwest
ernwest - avatar
1 Answer
+ 2
If you want to put the string between the <p> and </p>, you must use the "innerHTML" property... The "value" property goes with <input> tag ( essentially -- maybe some other tags ), and is an attribute of the tag, while innerHTML isn't ( it's the property which store the content part of the tag )...
23rd Dec 2016, 11:11 AM
visph
visph - avatar