JS实现-根据日期显示不同的图片...求代码...越简单越好...
展开全部
<script language="javascript">
var dd = (new Date()).getMonth();
switch(dd){
case 1:
case 2:
case 3:
document.getElementbyId("img1").src = "1.jpg";
break;
case 4:
case 5:
case 6:
document.getElementbyId("img1").src = "2.jpg";
break;
case 7:
case 8:
case 9:
document.getElementbyId("img1").src = "3.jpg";
break;
default:
document.getElementbyId("img1").src = "4.jpg";
}
</script>
var dd = (new Date()).getMonth();
switch(dd){
case 1:
case 2:
case 3:
document.getElementbyId("img1").src = "1.jpg";
break;
case 4:
case 5:
case 6:
document.getElementbyId("img1").src = "2.jpg";
break;
case 7:
case 8:
case 9:
document.getElementbyId("img1").src = "3.jpg";
break;
default:
document.getElementbyId("img1").src = "4.jpg";
}
</script>
追问
我已经写出来了...
var myDate=new Date();
moon = myDate.getMonth()+1;
day = myDate.getDate();
document.write("");
不过感谢..你这也是一种方法...相互学习学习...
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询