Get content of a DIV using JavaScript - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Div

Description

Get content of a DIV using JavaScript

Demo Code

ResultView the demo in separate window

<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 a2s  .  c o m*/
var MyDiv1 = document.getElementById('DIV1');
var MyDiv2 = document.getElementById('DIV2');
MyDiv2.innerHTML = MyDiv1.innerHTML;
    });

      </script> 
   </head> 
   <body> 
      <div id="DIV1">
          Blah blah. 
      </div> 
      <div id="DIV2"> 
      </div>  
   </body>
</html>

Related Tutorials