一個(gè)小BUG
先使用鼠標(biāo)點(diǎn)擊開(kāi)始,再使用鍵盤停止,發(fā)現(xiàn)需要摁兩次鍵盤;
先使用鍵盤開(kāi)始抽獎(jiǎng),再使用鼠標(biāo)停止,再使用鍵盤開(kāi)始抽獎(jiǎng)時(shí)需要摁兩次鍵盤;
先使用鼠標(biāo)點(diǎn)擊開(kāi)始,再使用鍵盤停止,發(fā)現(xiàn)需要摁兩次鍵盤;
先使用鍵盤開(kāi)始抽獎(jiǎng),再使用鼠標(biāo)停止,再使用鍵盤開(kāi)始抽獎(jiǎng)時(shí)需要摁兩次鍵盤;
2016-03-10
舉報(bào)
2016-03-24
加兩個(gè)flag就可以了
2016-03-11
我和你遇到了同樣的問(wèn)題
2016-03-11
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無(wú)標(biāo)題文檔</title>
<style type="text/css">
*{margin:0;padding:0}
.title{width:400px;
?????? height:70px;
?? ???? margin:0 auto;
?? ??? ?padding-top:30px;
?? ??? ?text-align:center;
?? ??? ?font-size:24px;
?? ??? ?color:#C00;
?? ??? ?font-weight:bold}
.btn{width:190px;
???? height:40px;
?? ? margin:0 auto;
?? ?}
.btn span{
?? ?float:left;
?? ?display:block;
?? ?width:80px;
?? ?height:27px;
?? ?background:#039;
?? ?text-align:center;
?? ?line-height:27px;
?? ?margin:7px;
?? ?color:#FFF;
?? ?font-size:14px;
??? font-family:"微軟雅黑";
??? cursor:pointer;
?? ?border-radius:6px;
?? ?}
</style>
<script>
var data=['iPhone6','謝謝惠顧','1000元購(gòu)物卡','謝謝惠顧','佳能單反','聯(lián)想筆記本','謝謝惠顧','50元話費(fèi)卡','蘋(píng)果耳機(jī)','謝謝惠顧']
timer=null;
flag=0
window.onload=function(){
?? ?var play=document.getElementById('play');
?? ?var over=document.getElementById('over');
?? ?play.onclick=playfun
?? ?over.onclick=overfun
?? ?document.onkeyup=function(event){
?? ??? event=event||window.event;
?? ??? if(event.keyCode==13)
?? ?? {
?? ???? if(flag==0){
?? ??? ? playfun();
?? ????? flag=1;
?? ??? ?}
?? ??? else{
?? ??? overfun();
?? ??? flag=0;
?? ??????? }
?? ?? }
?? ?? ?
?? }
}
?? ?
function playfun(){
?? ?var title=document.getElementById('title');
?? ?var play=document.getElementById('play');
?? ?clearInterval(timer);
?? ?timer=setInterval(function(){
?? ??? ?var random=Math.floor(Math.random()*data.length)
?? ??? ?title.innerHTML=data[random];
?? ??? ?},20)
?? ?play.style.background='#999'
?? ?flag=1;
?? ?}?? ?
?? ?
function overfun(){
?? ?clearInterval(timer);
?? ?var play=document.getElementById('play');
?? ?play.style.background='#039'
?? ?flag=0;
?? ?}
?? ?
?? ?
</script>
</head>
<body>
<div id="title" class="title">開(kāi)始抽獎(jiǎng)啦!</div>
<div class="btn"
>
<span id="play">開(kāi)始</span>
<span id="over">結(jié)束</span>
</div>
</body>
</html>
2016-03-10
把代碼貼出來(lái)吧這樣不好發(fā)現(xiàn)錯(cuò)誤。