Set text for <p> - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Paragraph

Description

Set text for <p>

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <h1>My Web Page</h1> 
      <p id="demo">A Paragraph.</p> 
      <p id="myDIV">A DIV.</p> 
      <button type="button" onclick="myFunction()">Try it</button> 
      <script>
function myFunction()//from   www  .  jav a  2s . co  m
{
document.getElementById("demo").innerHTML="Hello Dolly";
document.getElementById("myDIV").innerHTML="How are you?";
}

      </script>  
   </body>
</html>

Related Tutorials