I'm looking to customize the background, font style, and outline for both open and closed elements in the code snippet below:
a.innerHTML = "We are Open now now.";
a.innerHTML = "We are Closed, arm.";
Additionally, I want to apply different styling to the text displayed within this JavaScript code block. While I could use CSS to format it, I am unsure how to achieve that with JavaScript. Can you provide me with some examples?
var a = document.getElementById("hoursofoperation");
var d = new Date();
var n = d.getDay();
var now = d.getHours() + "." + d.getMinutes();
var weekdays = {
0: null,//Sunday
1: [8.30, 21.30],
2: [6.00, 11.30],
3: [8.30, 12.00],
4: [8.30, 12.00],
5: [8.30, 12.30],
6: null //Saturday
};
var dayWorkingHours = weekdays[n];//Today working hours. if null we are close
if (dayWorkingHours && (now > dayWorkingHours[0] && now < dayWorkingHours[1])) {
a.innerHTML = "We are Open now now.";
} else {
a.innerHTML = "We are Closed, kar.";
}