Change element content with innerHTML - Javascript DOM

Javascript examples for DOM:Element innerHTML

Description

Change element content with innerHTML

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <h1 id="myid"> what can javascript Do?</h1> 
      <p id="demo">Javascript can change html content.</p> 
      <button type="button" onclick="myFunction()"> Click Me!</button> 
      <script type="text/javascript">
        function myFunction() {//from w  w  w .  j a va2  s  . c  o  m
            document.getElementById('demo').innerHTML = 'hello javascript';
        }
        
      </script>  
   </body>
</html>

Related Tutorials