js设置div背景图片
<script>varnow=newDate()vartime=now.getHours()if(time>=6&&time<14){document.getElemen...
<script>
var now=new Date()
var time=now.getHours()
if(time>=6&&time<14){
document.getElementById("logo2").style.backgroundImage = "url(xxx)";
}
if(time>=14&&time<18){
document.getElementById("logo2").style.backgroundImage = "url(xxx)";
}
if(time>=18&&time<=23){
document.getElementById("logo2").style.backgroundImage = "url(xxx)";
}
</script>
<div id="logo2" style="width:100px;height:100px;"><div>
这样怎么没用 展开
var now=new Date()
var time=now.getHours()
if(time>=6&&time<14){
document.getElementById("logo2").style.backgroundImage = "url(xxx)";
}
if(time>=14&&time<18){
document.getElementById("logo2").style.backgroundImage = "url(xxx)";
}
if(time>=18&&time<=23){
document.getElementById("logo2").style.backgroundImage = "url(xxx)";
}
</script>
<div id="logo2" style="width:100px;height:100px;"><div>
这样怎么没用 展开
若以下回答无法解决问题,邀请你更新回答
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询