Javascript examples for DOM HTML Element:Div
Add text to a tag using innertext and add to an id of a div
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w w w . jav a 2s. c om var example = document.getElementById('divone'); var h1 = document.createElement('h1'); h1.innerText = "hi"; example.appendChild(h1); } </script> </head> <body> <div id="divone"> </div> </body> </html>