I am attempting to implement two different styles based on the time of day.
Here is the code I am using to select the CSS file depending on the current time:
<script type="text/javascript">
function setTimedStylesheet() {
var currentTime = new Date().getHours();
console.log(currentTime);
if (9 <= currentTime&¤tTime < 17) {
document.write("<link href='/nuvoladigital.com.br/css/stylesnight.css' rel='stylesheet' type='text/css'>");
}
if (17 <= currentTime&¤tTime < 9) {
document.write("<link href='/nuvoladigital.com.br/css/stylesnight.css' rel='stylesheet' type='text/css'>");
}
}
setTimedStylesheet();
</script>
<noscript><link href="/nuvoladigital.com.br/css/stylesnight.css" rel="stylesheet" type="text/css"></noscript>
The paths are correct, and the console log confirms that the JavaScript is correctly determining the time. However, the stylesheet is not being applied. Any ideas on what could be causing this issue?