1. 程式人生 > >單擊循環事件

單擊循環事件

else image function cti fun tel var onclick ima

<body>
<img src="images/hot.jpg" id="imgId"/>
</body>
<script>
i=0;
var imgObj=document.getElementById("imgId");
imgObj.onclick=function(){
if(i%2==0){
this.src="images/hot1.jpg"
}else{
this.src="images/hot.jpg"
}
i++;
}
</script>

單擊循環事件