2012-02-18 109 views
0

這行代碼基本上,我有這樣的:文件撰寫這行代碼週一至週六和週日

document.write('DIVS/HTML go here') 

,只在星期天,我希望它是:

document.write(' ') 

空了,但仍然在那裏,以防萬一我想用特定的日子填充它。

我該如何在我的JS文件中完成此操作?

回答

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