Create a Heading Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Heading


You can create a heading element by using the document.createElement() method:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">create a H1 element with some text</button>

function myFunction() {//from   ww w .  ja  va2  s.  co m
    var x = document.createElement("H1");
    var t = document.createTextNode("Welcome");


Related Tutorials