+ 4

Why doesnt work?

I am new to JS. Could you tell me why getElementById returns null in my code? https://code.sololearn.com/WowXLP1nO5qU/?ref=app

28th Jul 2017, 1:08 PM
Allan Chain
Allan Chain - avatar
1 Answer
+ 5
Because the document isn't loaded when you try to get the element. Use this instead: window.onload = function() { cir(); } This will wait for the document to load before doing anything
28th Jul 2017, 1:26 PM
The Coding Sloth
The Coding Sloth - avatar