JSFiddle - React, Tailwind, and code Playground
by thillin
HTML
<div class="face_icon"></div>
CSS
.face_icon {
background: red url(/img/face.png) no-repeat center;
height: 30px;
width: 300px;
}
JavaScript
var today = new Date(),
dd = today.getDate(); // Get Day
mm = today.getMonth() + 1, // Get Month and add 1 (January is 0)
yyyy = today.getFullYear(), // Get Year
fullDate = dd + '-' + mm + '-' + yyyy, // Format a date
specialDates = ['7-12-2014', '25-12-2014', '31-12-2014' ]; // List of special dates
for (var i in specialDates) { // Iterate through the specialDates array to see if any match today's date
if (fullDate == specialDates[i]) { // If today matches one of them, do this:
//alert('Special Date' + specialDates[i]); Dev: Proving it's getting the address
var url = 'url(/img/special/' + fullDate + '.png)'
$('.face_icon').css('background-image', url); //Change the background image to one in this format: 'img/special/7-12-2014.png'
}
}