Javascript examples for DOM:Document createElement
Add elements to the DOM with plain text HTML using JavaScript
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {/*from ww w .j av a 2 s.co m*/ var el = document.createElement("h1") el.id="title"; el.innerHTML = "Some title"; document.body.appendChild(el); var el2 = document.createElement("span") el2.style.display="block"; el2.style.width="100%"; el2.innerHTML = "Some arb text"; document.body.appendChild(el2); }); </script> </head> <body> </body> </html>