Last active
February 4, 2016 20:03
-
-
Save andrejewski/4893a10ca4c23893bfc6 to your computer and use it in GitHub Desktop.
Display "Happy {day of week}!" in any .x-happy-day tag
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
(function() { | |
var days = [ | |
"Sunday", | |
"Monday", | |
"Tuesday", | |
"Wednesday", | |
"Thursday", | |
"Friday", | |
"Saturday" | |
]; | |
function happyDay($els) { | |
Array.prototype.map.call($els, function($el) { | |
$el.innerText = "Happy "+days[(new Date()).getDay()]+"!"; | |
}); | |
} | |
this.happyDay = happyDay; | |
happyDay(document.querySelectorAll(".x-happy-day")); | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment