+ 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

16th Dec 2017, 4:20 PM
Damilola Daramola
Damilola Daramola - avatar
4 Réponses
+ 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
16th Dec 2017, 4:41 PM
SalahDEV
SalahDEV - avatar
+ 4
if you use jquery instead of js its easier
16th Dec 2017, 4:23 PM
Theprogrammers
Theprogrammers - avatar
+ 1
From what I understood... Self closing tag make use of ".value" while other tags uses the innerHTML
23rd Dec 2017, 11:12 AM
Damilola Daramola
Damilola Daramola - avatar
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
21st Apr 2018, 12:45 AM
Damilola Daramola
Damilola Daramola - avatar