Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.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 周一到周六写这行代码,周日写这行代码_Javascript_Date_Document.write - Fatal编程技术网

Javascript 周一到周六写这行代码,周日写这行代码

Javascript 周一到周六写这行代码,周日写这行代码,javascript,date,document.write,Javascript,Date,Document.write,基本上,我有: document.write('DIVS/HTML go here') 只有在星期天,我希望它是: document.write(' ') 空的,但仍在那里,以防我真的想用那天的东西填满它 如何在JS文件中实现这一点 if (new Date().getDay() == 0) { /* it's Sunday */ } else { /* it's not Sunday */ } if((new Date()).getDay() >=1) {

基本上,我有:

document.write('DIVS/HTML go here')
只有在星期天,我希望它是:

document.write(' ')
空的,但仍在那里,以防我真的想用那天的东西填满它

如何在JS文件中实现这一点

if (new Date().getDay() == 0)
{
    /* it's Sunday */
}
else
{
    /* it's not Sunday */
}
if((new Date()).getDay() >=1)
{
    // Monday - Saturday
    document.write('DIVS/HTML go here');
}
else
{
    // Sunday
    document.write(' ');
}