Skip to content

Instantly share code, notes, and snippets.

@kartset
Created August 13, 2020 04:25
Show Gist options
  • Save kartset/fd084b27d88d0a17637a6beed93ec5d4 to your computer and use it in GitHub Desktop.
Save kartset/fd084b27d88d0a17637a6beed93ec5d4 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Declare a Function</title>
</head>
<body>
<h1>Declare a function</h1>
<div>
<h2>Today's Date</h2>
<span id="calender"></span>
<input type="button" id="myButton" value="Get Date" onclick="showDate()">
</div>
<script>
//Declare your function
function showDate() {
var today = new Date();
var myCalender = document.getElementById("calender");
var myButton = document.getElementById("myButton");
myCalender.innerHTML = today.toDateString();
myButton.value = "Well Done !";
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment