Created
October 20, 2017 14:50
-
-
Save stefany-newman/327226045610b0ba18343f18e0b28a73 to your computer and use it in GitHub Desktop.
Add class to a dd elements based on the day of the week
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
var now = new Date(); | |
var all_days = [].slice.call(document.querySelectorAll('dd')); | |
var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; | |
var today = days[ now.getDay() ]; | |
all_days.forEach(function(node) | |
{ | |
var text = node.dataset.open; | |
if(text != undefined) | |
{ | |
if(node.dataset.open.indexOf(today) != -1){ | |
node.className = 'bold'; | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment