document.周一-周六写这行代码,周日写这行码

document.write this line of code Mon-Sat and this line of code on Sundays

本文关键字:周日 代码 周一 -周 document      更新时间:2023-09-26

基本上,我有这个:

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(' ');
}