Get the paragraph tag and set its innerHTML value : innerHTML « Node Operation « JavaScript DHTML






Get the paragraph tag and set its innerHTML value

  

<html>
<head>
    <title>the date</title>
</head>
<body>
    <p id="dateField"></p>
    
    <script type = "text/javascript">
    var today = new Date();
    var then = new Date();

    then.setFullYear(3000,1,1);
    
    var diff = then.getTime() - today.getTime();
    
    diff = Math.floor(diff / (1000 * 60 * 60 * 24));
    
    var dateLoc = document.getElementById("dateField");
    
    dateLoc.innerHTML = diff + " days";
    </script>

</body>
</html>

   
    
  








Related examples in the same category

1.'innerHTML' Example
2.Switch html with assigning the innerHTML
3.Modifying Elements after Page loads