+ 1
How can I access a span inside <li> in <ol> in JS?[SOLVED]
<ol> <li> <span id="some"></span> </li> </ol> //Js document.getElementById("some").innerHTML = "Text"; This JS code is not working.
5 Answers
+ 4
Let me guess...
'Cannot set property innerHTML of null' ?
Your script is executed before DOM being loaded properly. Try this:
window.onload = function() {
document.getElementById("some").innerHTML = "Text";
}
+ 2
Hatsy Rei Thank You so much sir.
+ 1
Hatsy Rei Saying Cannot set the propery 'innerHTML' of undefined
?????
+ 1
Hatsy Rei Sorry sir, I mistakenly tapped on downvote.
Am building a web app.
And am facing the problem in function genderWord()
Please have a look over this.
https://code.sololearn.com/Wg3qbEDHZucB/?ref=app