+ 1

Why document.getElementById("validId ") return null even though the document is loaded and the id is valid.

Why dors document.getElementById("validId ") return null even though the document is loaded and the id is valid. https://code.sololearn.com/WVIHIywjw4u4/?ref=app

13th Mar 2018, 5:28 PM
josh mizzi
josh mizzi - avatar
7 Respuestas
+ 3
this.onload expects a function, not a function call. So it should be "this.onload = load;" Otherwise "load" is not called as soon as the onload event occurs, but immediately on execution (=> before rendering).
13th Mar 2018, 5:57 PM
kokossplitter
+ 11
@Josh Have you looked at the setInterval tag? it would enable you to animate the progress bar.
13th Mar 2018, 6:21 PM
jay
jay - avatar
13th Mar 2018, 6:06 PM
Baraa AB
Baraa AB - avatar
+ 2
Obviously it will show null. After all there is nothing inside the progress tag!
13th Mar 2018, 5:57 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 2
I am aware of it. But thanks
13th Mar 2018, 6:22 PM
josh mizzi
josh mizzi - avatar
+ 2
@kokossplityer Thanks, your suggestion was what I needed.
13th Mar 2018, 6:26 PM
josh mizzi
josh mizzi - avatar
+ 1
@cHiRaG GhOsH You are mistaken. A pair of tag does not need to have any contents for it to not equal null. document.getElementById returns an object representing the node not the contents of the tags. The .InnerHTML property represents the tags contents.
13th Mar 2018, 6:13 PM
josh mizzi
josh mizzi - avatar