Get DOM element by id and set html content - Javascript DOM

Javascript examples for DOM:Document getElementById

Description

Get DOM element by id and set html content

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 va  2 s .co  m*/
document.getElementById('logo').innerHTML='<content to be added>';
    });

      </script> 
   </head> 
   <body> 
      <div id="content"> 
         <div id="logo"> 
            <p> Blah Blah Blah </p> 
         </div> 
      </div>  
   </body>
</html>

Related Tutorials