Skip to content

Instantly share code, notes, and snippets.

@stefany-newman
Created October 20, 2017 14:50
Show Gist options
  • Save stefany-newman/327226045610b0ba18343f18e0b28a73 to your computer and use it in GitHub Desktop.
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
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