How do you insert a new element into a Html body tag in Javascript?

  • Thread starter Thread starter Listen 2 Ur Sensei
  • Start date Start date
L

Listen 2 Ur Sensei

Guest
Here is the html file:

<html>
<head>
<title>

</title>
<script type = "text/javascript" src = "MakingHeaders.js"/>
</script>

</head>

<body>



</body>

</html>


Here is the javascript code:

var Heading = document.createElement("h1");
var newHead = document.createTextNode("This is a Heading");
Heading.appendChild(newHead);
var Insert = document.getElementsByTagName("body")[0];
Insert.appendChild(Heading);


//After the [0] is a semicolon not ...
 
Back
Top