0
document.write() vs. print()
I've noticed that this course uses document.write, but when I switch that out with "print", I get an error. However, when I execute js code in my browser via an html document, "print" works, but "document.write" doesn't. What is the difference and why the errors...
1 Respuesta
0
Both of these ways how to write some text into document aren't correct. Well, they are but nobody make it so because it's stupid. Try to use innerHTML. :)
HTML part:
<div id="demo"></div>
JS part:
document.getElementById("demo").innerHTML = "Hello world!";