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.
3 ответов
+ 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.
0
can you show us your code
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>