Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 日复一日地改变js html_Javascript_Html_Days - Fatal编程技术网

Javascript 日复一日地改变js html

Javascript 日复一日地改变js html,javascript,html,days,Javascript,Html,Days,我有一个密码: var dayNames=新阵列星期五、星期三、星期四、星期五、, 星期三、星期四、星期五; var now=新日期; document.writeBuy nowe,您可以在+dayNames[now.getDay]上获取它; 这样-我假设周五之后的14:00和周三之前的14:00意味着周三交货 const dayNames=[星期三、星期三、星期四、星期五、星期三、星期四、星期五]; 让我们现在=新的日期; 如果now.getHours>=14 now.setDatenow

我有一个密码:

var dayNames=新阵列星期五、星期三、星期四、星期五、, 星期三、星期四、星期五; var now=新日期; document.writeBuy nowe,您可以在+dayNames[now.getDay]上获取它;
这样-我假设周五之后的14:00和周三之前的14:00意味着周三交货

const dayNames=[星期三、星期三、星期四、星期五、星期三、星期四、星期五]; 让我们现在=新的日期; 如果now.getHours>=14 now.setDatenow.getDate+1 document.writeBuy nowe,您可以在+dayNames[now.getDay]上获取它; 试试这个

var now = new Date();
var day = now.getDay();
if (now.getHours() >= 14){
    day += 1;
}

document.write("Buy nowe, you geti it on " + dayNames[day]);

您可以将时间设置为从现在起14小时。因此,如果是下午2点或之后,将被视为第二天及之后的12:00

let shippingTime = new Date();
shippingTime.setHours(shippingTime.getHours() + 14);

document.write("Buy now, you get it on " + dayNames[shippingTime.getDay()]);

<a id="orderBy"></a>

您的预期输出是什么?当白天大于阵列长度时,这将在所有周六失败