一个简易的抽奖大转盘

代码如下

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Price Draw</title>
<style>
table{
border:1px solid black;
}
td{
border:1px solid black;
width:50px;
height:50px;
}
a{
text-decoration:none;
color:black;
}
</style>
<script>
var id = 0;
function start(){
var tds = document.getElementsByTagName("td");
for(var idx = 0; idx < tds.length; idx ++){
var mya = tds[idx];
mya.style.backgroundColor = "red";
}

var time = Math.ceil(Math.random()*24+20);
var stop;
var index = 0;
id = 0;
var preId = 1;
stop = setInterval(function(){
index++;
id++;
var pretd = document.getElementById(preId+"");
pretd.style.backgroundColor = "white";
var td = document.getElementById(id+"");
td.style.backgroundColor = "yellow";
preId = id;
if(id>=8){
id = 0;
}

if(index>=time){
clearInterval(stop);
}

},100);
}
</script>
</head>
<body>
<table id="table">
<tr>
<td id="1">50</td>
<td id="2">100</td>
<td id="3">150</td>
</tr>
<tr>
<td id="8">200</td>
<td><a href="#" οnclick="start();return false;">开始</a></td>
<td id="4">300</td>
</tr>
<tr>
<td id="7">350</td>
<td id="6">400</td>
<td id="5">500</td>
</tr>
</table>
</body>
</html>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值