JavaScript: Difference between revisions

Content deleted Content added
m Example script: rm unnecessary whitespace
Example script: Replaced DOM 1.0 document.write (VERY bad practise) with DOM text nodes
Line 305:
<h1 id="header">This is JavaScript</h1>
<script type="text/javascript">
document.writeappendChild(document.createTextNode('Hello World!'));
var h1 = document.getElementById("header"); // holds a reference to the <h1> tag
h1 = document.getElementsByTagName("h1")[0]; // accessing the same <h1> element