Last active
December 14, 2015 04:49
-
-
Save kranthilakum/5031127 to your computer and use it in GitHub Desktop.
Display current day of the week using JavaScript getDay()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
function today() | |
{ | |
var day = new Date(); | |
var dayNames = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", | |
"Thursday", "Friday", "Saturday"); | |
var x = document.getElementById("myDay"); | |
x.innerHTML = "Happy " + dayNames[day.getDay()] + "!"; | |
} | |
</script> | |
</head> | |
<body onload="today()"> | |
<p id="myDay"></p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment