Javascript examples for DOM:Element appendChild
Using AppendChild on body element with text content
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w w w . ja v a 2s.com var infoDiv = document.createElement("div"); infoDiv.setAttribute("class", "text-block"); var bio = document.createElement("strong"); bio.textContent = "Bio"; infoDiv.appendChild(bio); infoDiv.innerHTML += "Full"; document.getElementsByTagName("body")[0].appendChild(infoDiv) } </script> </head> <body> </body> </html>