亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

基于javascript實(shí)現(xiàn)簡(jiǎn)單的抽獎(jiǎng)系統(tǒng)

 更新時(shí)間:2020年04月15日 14:41:17   作者:請(qǐng)叫我吳陽(yáng)光  
這篇文章主要為大家詳細(xì)介紹了基于javascript實(shí)現(xiàn)簡(jiǎn)單的抽獎(jiǎng)系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了js實(shí)現(xiàn)簡(jiǎn)單的抽獎(jiǎng)系統(tǒng),供大家參考,具體內(nèi)容如下

<!doctype html>
<html lang="en">
<head>
 <meta charset="gb2312">
 <title>抽獎(jiǎng)活動(dòng)</title>
 <style>
*{
 margin:0;padding:0;
}
#title{
 color:red;text-align:center;margin:0 auto;width:240px;height:70px;padding-top:10px;background:opacity(0);
}
.btns{
 width:190px;height:30px;margin:0px auto;
}
 
.btns span{
 display:block;float:left;width:80px;height:28px;text-align:center;background:#036;color:#fff;cursor:pointer;border:1px solid #eee;border-radius:8px;font-family:"微軟雅黑";font-size:14px;line-height:28px;margin-right:10px;
}
#txt{
 font-size:14px;color:#ccc999;text-align:center;margin:0 auto;width:190px;height:50px;padding-top:10px;
}
 </style>
 <script>
 var mytype=["iPhone6s","iPad Air2","DELL外星人","鍵鼠套裝","1000元超市購(gòu)物卡","200元話費(fèi)充值卡","謝謝參與","品牌耳機(jī)","港澳臺(tái)7日游","50元優(yōu)惠券"],//定義獎(jiǎng)品池
  timer=null,
  count=0;
//加載時(shí)觸發(fā)
 window.onload=function(){
 var start = document.getElementById("start");
 var stop = document.getElementById("stop");
 
 start.onclick=startFun;//這個(gè)函數(shù)后面加括號(hào),就直接調(diào)用了該函數(shù),所以不要加
 stop.onclick=stopFun;
 
 //綁定鍵盤事件
 document.onkeyup=function(e){
  e = e || window.event;
 if(e.keyCode==13){
  if(count==0){
  startFun();
  count=1;
  }
 else{ 
  stopFun();
  count=0;
  }
 }
 }
 }
 
//點(diǎn)擊開始,標(biāo)題欄開始輪動(dòng)
 function startFun(){
 clearInterval(timer);//開始時(shí),清除計(jì)時(shí)器,避免二次觸發(fā)
 var title = document.getElementById("title");
 var start = document.getElementById("start");
 
 timer = setInterval(function(){
  var num= Math.floor(Math.random()*mytype.length);
  title.innerHTML=mytype[num];
 },50);
 start.style.background="#ccc";
 
 }
 //點(diǎn)擊停止,標(biāo)題欄停止輪動(dòng)并輸出輪動(dòng)結(jié)果
 function stopFun(){
 var start = document.getElementById("start"),
  txt = document.getElementById("txt"),
  title = document.getElementById("title");
 clearInterval(timer);//清除計(jì)時(shí)器,停止計(jì)時(shí)器
 start.style.background="#036";
 }
 
 
 </script>
<body>
 <div>
 <h2 id="title">開始抽獎(jiǎng)!</h2>
 </div>
 <div class="btns">
 <span id="start">開始</span>
 <span id="stop">停止</span>
 </div>
 <div id="txt">支持回車鍵(Enter)開始/停止。</div>
</body>
</html>

效果圖:

想要學(xué)習(xí)更多關(guān)于javascript抽獎(jiǎng)功能,請(qǐng)參考此專題:javascript實(shí)現(xiàn)抽獎(jiǎng)功能

實(shí)現(xiàn)的功能就是這么簡(jiǎn)單,希望大家可以中大獎(jiǎng)哦!

相關(guān)文章

最新評(píng)論