Javascript examples for DOM HTML Element:Heading
You can create a heading element by using the document.createElement() method:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">create a H1 element with some text</button> <script> function myFunction() {//from ww w . ja va2 s. co m var x = document.createElement("H1"); var t = document.createTextNode("Welcome"); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>