在这里插入代码片
<style type="text/css">
body{
height:500px;
background-image:url(images/hfbj1.jpg);
}
</style>
</head>
<body>
<script src="./public.js"></script>
<script>
window.onload=function showImg(){
setInterval(createImg,1000);
function createImg(){
var oImg=document.createElement("img");
document.body.appendChild(oImg);
oImg.src="dishu.png";
var w=rand(50,200)
oImg.width=oImg.height=w;
oImg.style.position="absolute";
oImg.style.top=rand(0,window.innerHeight-w)+"px";
oImg.style.left=rand(0,window.innerWidth-w)+"px";
oImg.alt="地鼠";
setTimeout(hide,5000)
function hide(){
document.body.removeChild(oImg)
}
oImg.onclick = function(){
this.remove();
}
}
}
</script>
<input type="button" value="换肤" />
<script>
var c=document.getElementsByTagName("input")[0];
var index=1;
c.onclick=function(){
var body=document.querySelector("body");
index++;
if(index==5){
index=1;
}
body.setAttribute("style","background-image:url(images/hfbj"+index+'.jpg)')
}
</script>
</body>