Create <H1> element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Heading

Description

Create <H1> element

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script>
var greeting = "Hi";
var greet = function (){;/*from  w  w w  .ja v a  2 s . com*/
console.log(greeting)
};
greet();
console.log(greeting);
var h = document.createElement("H1");
var t = document.createTextNode(greeting);
h.appendChild(t);
document.body.appendChild(h);

      </script> 
      <h1>Hello</h1> 
      <p>World</p> 

      <script>
console.log(5 + 6);
console.log(greeting);

      </script>  
   </body>
</html>

Related Tutorials