Alternatives to document.write - Javascript DOM

Javascript examples for DOM:Element innerHTML

Description

Alternatives to document.write

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <div id="myDiv1"></div> 
      <div id="myDiv2"></div>  
      <script type="text/javascript">
        var myDiv1 = document.getElementById("myDiv1");
        var myDiv2 = document.getElementById("myDiv2");
        myDiv1.innerHTML = "<b>Content of 1st DIV</b>";
        myDiv2.innerHTML = "<i>Content of second DIV element</i>";
    //from   w w w  .  j  a v  a 2 s .co  m
      </script> 
   </body>
</html>

Related Tutorials