0

When using the getElementById() in JavaScript, it's returning null. Anyone with solutions

getElementById returns null each time I call it and it is preventing my from using innerHTML or others because I can't change the value of null. Though I haven't tried it on computer browser yet.

5th Nov 2016, 12:27 PM
Monday Stephen Osere
Monday Stephen Osere - avatar
3 Réponses
+ 1
I have that same problem, I have solved it by rewriting p tag. I thick complier does not understand that you have write p tag.
5th Nov 2016, 2:28 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
0
can you show us your code
5th Nov 2016, 1:23 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
0
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> if (Math.random() < 0.5) {     text = "<a href='http://w3schools.com'>Visit W3Schools</a>"; } else {     text = "<a href='http://wwf.org'>Visit WWF</a>"; } document.getElementById("demo").innerHTML = text; </script> </body> </html>
5th Nov 2016, 1:45 PM
Monday Stephen Osere
Monday Stephen Osere - avatar