不同时间段 显示不同的图片

前天朋友需要不同时间段显示不同图片,就找下代码自己修改了一下。用得到的人应该很少。。。

<dt id="nihaome"><img src="图片路径" ></dt>

<script>

var ab=new Date();

var hours = ab.getHours();

if(hours>=0&&hours<12){

 

   num1="<img style=width:488px; height:488px; src='https://287587.com/wp-content/uploads/2021/11/9035bb84af21.jpg'/>";

document.getElementById("nihaome").innerHTML=num1;

}

if(hours>=12&&hours<14){

 

   

 num1="<img style=width:488px; height:488px; src='https://287587.com/wp-content/uploads/2021/11/9035bb84af21.jpg'/>";

document.getElementById("nihaome").innerHTML=num1;

}

if(hours>=14&&hours<16){

 num1="<img style=width:488px; height:488px; src='https://287587.com/wp-content/uploads/2021/11/cddfb3adb339.jpg'/>";

document.getElementById("nihaome").innerHTML=num1;

}
if(hours>=18&&hours<20){

 num1="<img style=width:488px; height:488px; src='https://287587.com/wp-content/uploads/2021/11/cddfb3adb339.jpg'/>";

document.getElementById("nihaome").innerHTML=num1;

}
if(hours>=20&&hours<22){

 num1="<img  style=width:488px; height:488px; src='https://287587.com/wp-content/uploads/2021/11/cddfb3adb339.jpg'/>";

document.getElementById("nihaome").innerHTML=num1;

}
if(hours>=22&&hours<24){

 num1="<img style=width:488px; height:488px; src='https://287587.com/wp-content/uploads/2021/11/cddfb3adb339.jpg'/>";

document.getElementById("nihaome").innerHTML=num1;

}

</script>
© 版权声明
THE END
喜欢就支持一下吧
点赞0
分享
评论 抢沙发
dadudu的头像-淡墨源码网

昵称

取消
昵称表情代码图片