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...

21st Sep 2016, 8:23 PM
Jameyson Mac Donald
Jameyson Mac Donald - avatar
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!";
8th Oct 2016, 5:17 PM
Jakub ADAMEC
Jakub ADAMEC - avatar