我想根据一天中的时间更改内容,这表明我的业务是开放还是关闭。我使用以下Javascript:如何根据当天的时间更改留言?
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
var dt = new Date();
var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
enter code here
if (day <= 0) {
if (time < "11:00:00") {
document.write('Good morning! We are currently closed, you can reach us at 11 AM')
} else if (time > "16:30:00" && time < "18:00:00") {
document.write('Good afternoon! We are currently closed. You can reach us tomorrow')
} else if (time > "18:00:00") {
document.write('Good evening! We are currently closed. You can reach us tomorrow')
} else {
document.write('Customer service: <i class="fa fa-phone"></i> +1 555.234.987')
}
} else if (day <= 1) {
if (time < "09:00:00") {
document.write('Good morning! We are currently closed, you can reach us at 9 AM')
} else if (time > "19:00:00") {
document.write('Good evening! We are currently closed, you can reach us tomorrow')
} else {
document.write('Customer Service: <i class="fa fa-phone"></i> +1 555.234.987')
}
}
</script>
等等从星期一到星期天。
出于某种原因,文本显示其他文本,所以当它是在周一上午10点,文本显示“晚上好!目前,我们正在关闭,就可以达到我们的明天”
我知道我做错了什么,但我不知道什么...
我试过这个,但控制台说有一个意外的标记案例 – Wouhero 2014-12-14 10:45:42
不能帮助,如果我没有看到你创建的代码。也许你可以用你的新代码制作一个[小提琴](http://jsfiddle.net/)或者在你的问题中编辑它。 – 2014-12-15 09:14:48