<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>這個是一個抽獎系統(tǒng)的代碼,開始點開始便開始抽獎,點stop就停止,但是現(xiàn)在問題是,我點stop沒用。求解問題出在哪。謝謝各位
求各位大哥幫忙查查錯誤,我實在找不出了
Sprash
2016-03-21 18:39:53