Set and remove value to and from <p> element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Paragraph

Description

Set and remove value to and from <p> element

Demo Code

ResultView the demo in separate window

<html>
   <body> 
      <button type="button" onclick="document.getElementById('demo').innerHTML = Date()"> display Date and Time. </button> 
      <button type="button" onclick="Empty()"> delete Date and Time. </button> 
      <script>
function Empty(){/* w  w  w  .  j a va2  s.c om*/
document.getElementById('demo').innerHTML = "";
}

      </script> 
      <p id="demo"></p>  
   </body>
</html>

Related Tutorials