I'm in the process of creating a website. I'm displaying the opening hours. And the client has asked for the current day of the week to be highlighted.E.G. every day is displayed in the color black box but today's date is in a red box.
var d = new Date();
var weekday = new Array(7);
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
var n = weekday[d.getDay()];
if (n = 'Thursday') {
$('coloured-box').css({"color":"green"});
}
The above is what I have no idea if it's right wrong or nearly there.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…