The Old and Classic JavaScript Sample Code

Published on Wednesday, October 2, 2013

Let me copy the old but classic JavaScript sample code from w3schools:

<!DOCTYPE html>      
<html>       
<head>       
<script>       
function displayDate()       
{       
document.getElementById("demo").innerHTML=Date();       
}       
</script>       
</head>       
<body>
    
<h1>My First JavaScript</h1>      
<p id="demo">This is a paragraph.</p>
    
<button type="button" onclick="displayDate()">Display Date</button>
    
</body>      
</html> 
 

The result will display current server time:

image