Create and append text in the body using JavaScript - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Body

Description

Create and append text in the body using JavaScript

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Number guessing game</title> 
   </head> 
   <body>  
      <script type="text/javascript">
  var par = document.createElement("p");
  var text = document.createTextNode("fhsgdjrs hgrtsfya");
  par.appendChild(text);/*from  w  ww .j av a2  s. c  o  m*/
  document.getElementsByTagName('body')[0].appendChild(par);

      </script> 
   </body>
</html>

Related Tutorials