Update <p> in a function - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Paragraph

Description

Update <p> in a function

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(){//  w  w  w.  j av  a 2 s.  c  om
document.getElementById("demo1").innerHTML="This is my test heading";
function displaytext()
{
    document.getElementById("demo").innerHTML="This is from a javascipt function...";
}
displaytext();

    }

      </script> 
   </head> 
   <body> 
      <p id="demo1">This is demo1.</p> 
      <p id="demo">This is a paragraph.</p>  
   </body>
</html>

Related Tutorials