码迷,mamicode.com
首页 > 其他好文 > 详细

图片抽奖

时间:2018-09-11 00:59:40      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:else   tin   ==   asc   head   interval   lan   lse   ref   

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
#container{
text-align: center;
}
</style>

</head>
<body>

<div id="container">

<a href="javascript:void(0)">
<img id="pic" src="1.jpg" width="100%" height="600" alt="hello"/>
</a>

</div>

<script>
var pic=document.getElementById("pic");
var t=null;
var i=1;
var j=1;
var k=0;
window.addEventListener("keyup",function (e) {
console.log(e.keyCode)
if(e.keyCode==13 || e.keyCode==32){
k++
if(k%2==1){
t=setInterval(function () {
if(i=100){
i=1
}
if(j>4){
j=1
}
pic.src=j+".jpg"
i++
j++
},100)
}else{
clearInterval(t)
}
}


})
</script>
</body>
</html>

图片抽奖

标签:else   tin   ==   asc   head   interval   lan   lse   ref   

原文地址:https://www.cnblogs.com/zhangchong/p/9623605.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!