Categories
How To Article Javascript

How to Show Date on button click through Javascript

Here is a example how to show the date when you click on the button through a javascript.

Code:-

<html>
<head>
<script type=”text/javascript”>
function displayDate()
{
document.getElementById(“hightech”).innerHTML=Date();
}
</script>
</head>
<body>
<h1>My First Web Page</h1>
<p id=”hightech”>Hightechnology.</p>
<button type=”button” onclick=”displayDate()”>Display Date</button>
</body>
</html>

Change accoding to your requirement.