<html>
<head><meta charset="utf-8">
<style type="text/css">
.wrap{
margin: 0 auto;
width: 400px;
height: 240px;
}
.price{
width: 300px;
height: 40px;
text-align: center;
line-height: 40px;
margin: 0 auto;margin-bottom: 20px;
}
.begin{
float: left;
background-color:blue;
color: white;
width: 90px;
text-align: center;
height: 35px;
line-height: 35px;
margin:0 20 0 80;
}
.stop{
float: left;
background-color:blue;
color: white;
width: 90px;
text-align: center;
height: 35px;
line-height: 35px;
margin:0 20 0 80;
}
</style>
</head>
<body>
<div class="wrap">
<div class="price" id="price">抽奖开始</div>
<button class="begin" id="begin">开始</button>
<button class="stop" id="stop">停止</button>
</div>
<script type="text/javascript">
var jp=['Phone5','Ipad','三星笔记本','佳能相机','惠普打印机','谢谢参与','50元充值卡','1000元超市购物券'];
var begin=document.getElementById("begin");
var stop=document.getElementById("stop");
var price=document.getElementById("price");
var timmer=null;
begin.onclick=a1;
stop.onclick=stopFun;
var i=0;
function a1(){
var timmer=setInterval(a11,100);
begin.style.backgroundColor="grey";
begin.style.color="white";
begin.onclick=null;
}
function a11()
{
price.innerHTML=jp[i];
i++;
if(i==jp.length){
i=0;
}
}
function stopFun(){
clearInterval(timmer);
}
</script>
</body>
</html>
这个是一个抽奖系统的代码,开始点开始便开始抽奖,点stop就停止,但是现在问题是,我点stop没用。求解问题出在哪。谢谢各位
woshiajuana