+ 1
Why does it flag "can't set innerHTML null" error when I use innerHTML to output a string. Can't figure out what's causing it
InnerHTML
4 Answers
+ 5
It depends on the output tag let's say you want to get the output of a self closing tag like input element then use:
in JS:
document.getElementById("#Your_ID_Name").value
in JQ:
$("#Your_ID_Name").val()
But If you want the output of the elements of type <el></el>
Then use:
in JS:
document.getElementById("#Your_ID_Name").innerHTML
in JQ:
$("#Your_ID_Name").text()
or
$("#Your_ID_Name").html() to get the markup text
+ 4
if you use jquery instead of js
its easier
+ 1
From what I understood... Self closing tag make use of ".value" while other tags uses the innerHTML
0
I found an answer to it... Is because the DOM has not been loaded before the executing the script...
https://code.sololearn.com/W9V6QU82bMJv/?ref=app