分时问候代码

2025-11-02 18:58:15

1、<script>

today=new Date();

var day; var date; var hello; var wel;

hour=new Date().getHours()

if(hour < 6)hello='凌晨好'

else if(hour < 9)hello='早上好'

else if(hour < 12)hello='上午好'

else if(hour < 14)hello='中午好'

else if(hour < 17)hello='下午好'

else if(hour < 19)hello='傍晚好'

else if(hour < 22)hello='晚上好'

else {hello='夜里好'}

if(today.getDay()==0)day='星期日'

else if(today.getDay()==1)day='星期一'

else if(today.getDay()==2)day='星期二'

else if(today.getDay()==3)day='星期三'

else if(today.getDay()==4)day='星期四'

else if(today.getDay()==5)day='星期五'

else if(today.getDay()==6)day='星期六'

date=(today.getYear())+'年'+(today.getMonth() + 1 )+'月'+today.getDate()+'日';

document.write(hello);

    </script>

<script>

document.write(date + ' ' + day + ' ' );

      </script>

2、修改分时问候文本的颜色为白色

显示网页中脚本元素步骤:

“编辑”菜单栏→首选参数→不可见元素→选择“脚本”,如下图所示:

方法一:拖动鼠标选中脚本标记,在属性面板下字体颜色设置为白色

方法二:应用<font></font>标记来修改字体颜色。

分时问候代码

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢