jQuery實(shí)現(xiàn)移動(dòng)端扭蛋機(jī)抽獎(jiǎng)
本文實(shí)例為大家分享了jQuery實(shí)現(xiàn)移動(dòng)端扭蛋機(jī)抽獎(jiǎng)的具體代碼,供大家參考,具體內(nèi)容如下
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="apple-touch-fullscreen" content="YES" /> <meta name="format-detection" content="telephone=no" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black" /> <meta http-equiv="Expires" content="-1" /> <meta http-equiv="pragram" content="no-cache" /> <link href="css/style.css" type="text/css" rel="stylesheet"/> <title>扭蛋機(jī)</title> <!--移動(dòng)端版本兼容 --> <script type="text/javascript"> var phoneWidth = parseInt(window.screen.width); var phoneScale = phoneWidth/640; var ua = navigator.userAgent; if (/Android (\d+\.\d+)/.test(ua)){ var version = parseFloat(RegExp.$1); // andriod 2.3 if(version>2.3){ document.write('<meta name="viewport" content="width=640, minimum-scale = '+phoneScale+', maximum-scale = '+phoneScale+', target-densitydpi=device-dpi">'); // andriod 2.3以上 }else{ document.write('<meta name="viewport" content="width=640, target-densitydpi=device-dpi">'); } // 其他系統(tǒng) } else { document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">'); } //微信去掉下方刷新欄 if(RegExp("MicroMessenger").test(navigator.userAgent)){ document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() { WeixinJSBridge.call('hideToolbar'); }); } </script> <script src="js/jquery1.8.3.min.js"></script> </head> <body> <div class="niu_danji"> <!--機(jī)器--> <div class="game_qu"> <!--go--> <div class="game_go">100/次</div> <div class="wdjifen">10000</div> </div> <!--球--> <div class="dan_gund"> <span class="qiu_1 diaol_1"></span> <span class="qiu_2 diaol_2"> </span> <span class="qiu_3 diaol_3"></span> <span class="qiu_4 diaol_4"></span> <span class="qiu_5 diaol_5"></span> <span class="qiu_6 diaol_6"></span>> <span class="qiu_7 diaol_7"></span> <span class="qiu_8 diaol_8"></span> <span class="qiu_9 diaol_9"></span> <span class="qiu_10 diaol_10"></span> <span class="qiu_11 diaol_11"></span> </div> <!--中獎(jiǎng)掉落--> <div class="medon"><img src="images/mendong.png"/></div> <div class="zjdl "> <span></span> </div> </div> <!--中獎(jiǎng) 獲得一等獎(jiǎng)--> <div class="zonj_zezc none" id="jianpin_one"> <div class="jpzs aiqiyi tc_anima"> <em><img src="images/close.png"/></em> <h2> <b>恭喜你!<br>獲得一等獎(jiǎng)!</b> </h2> </div></div> <!--中獎(jiǎng)獲得二等獎(jiǎng)--> <div class="zonj_zezc none" id="jianpin_two"> <div class="jpzs aiqiyi tc_anima"> <em><img src="images/close.png"/></em> <h2> <b>恭喜你!<br>獲得二等獎(jiǎng)!</b> </h2> </div> </div> <!--中獎(jiǎng) 獲得三等獎(jiǎng)--> <div class="zonj_zezc none" id="jianpin_three"> <div class="jpzs aiqiyi tc_anima"> <em><img src="images/close.png"/></em> <h2> <b>恭喜你!<br>獲得三等獎(jiǎng)!</b> </h2> </div> </div> <!--沒(méi)有中獎(jiǎng)--> <div class="zonj_zezc none" id="jianpin_kong"> <div class="jpzs aiqiyi tc_anima"> <em><img src="images/close.png"/></em> <h2> 咦?沒(méi)有抽中? </h2> </div> </div> <!--積分不足--> <div class="zonj_zezc none" id="no_jifeng"> <div class="jpzs aiqiyi tc_anima"> <em><img src="images/close.png"/></em> <h2> 對(duì)不起,積分不足! </h2> </div> </div> <script> $(document).ready(function(e) { //一等獎(jiǎng) 關(guān)閉 $("#jianpin_one em img").click(function(){ $("#jianpin_one").hide(); } ); //二等獎(jiǎng) 關(guān)閉 $("#jianpin_two em img").click(function(){ $("#jianpin_two").hide(); } ); //三等獎(jiǎng) 關(guān)閉 $("#jianpin_three em img").click(function(){ $("#jianpin_three").hide(); } ); //沒(méi)有中獎(jiǎng) 關(guān)閉 $("#jianpin_kong em img").click(function(){ $("#jianpin_kong").hide(); } ); //積分不足 關(guān)閉 $("#no_jifeng em img").click(function(){ $("#no_jifeng").hide(); } ); var score=470; $(".wdjifen").html(score); $(".game_go").click(function(){ score-=100; if(score<0){ for(i=1;i<=11;i++){ $(".qiu_"+i).removeClass("wieyi_"+i); } $("#no_jifeng").show(); }else{ draw() } }); function draw(){ var number =Math.floor(4*Math.random()+1); for(i=1;i<=11;i++){ $(".qiu_"+i).removeClass("diaol_"+i); $(".qiu_"+i).addClass("wieyi_"+i); }; setTimeout(function (){ for(i=1;i<=11;i++){ $(".qiu_"+i).removeClass("wieyi_"+i); } },1100); setTimeout(function(){ switch(number){ case 1:$(".zjdl").children("span").addClass("diaL_one");break; case 2:$(".zjdl").children("span").addClass("diaL_two");break; case 3:$(".zjdl").children("span").addClass("diaL_three");break; case 4:$(".zjdl").children("span").addClass("diaL_four");break; } $(".zjdl").removeClass("none").addClass("dila_Y"); setTimeout(function (){ switch(number){ case 1:$("#jianpin_one").show();break; case 2:$("#jianpin_two").show();break; case 3:$("#jianpin_three").show();break; case 4:$("#jianpin_kong").show();break; } },900); },1100) //取消動(dòng)畫(huà) setTimeout(function (){ $(".zjdl").addClass("none").removeClass("dila_Y"); $(".wdjifen").html(score); $(".zjdl").children("span").removeAttr('class'); },2500) } }); </script> </body> </html>
demo下載地址:jQuery移動(dòng)端扭蛋機(jī)抽獎(jiǎng)
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- jquery.rotate.js實(shí)現(xiàn)可選抽獎(jiǎng)次數(shù)和中獎(jiǎng)內(nèi)容的轉(zhuǎn)盤(pán)抽獎(jiǎng)代碼
- jquery 年會(huì)抽獎(jiǎng)程序
- jQuery實(shí)現(xiàn)轉(zhuǎn)動(dòng)隨機(jī)數(shù)抽獎(jiǎng)效果的方法
- jquery 抽獎(jiǎng)小程序?qū)崿F(xiàn)代碼
- jquery實(shí)現(xiàn)九宮格大轉(zhuǎn)盤(pán)抽獎(jiǎng)
- jQuery實(shí)現(xiàn)類(lèi)似老虎機(jī)滾動(dòng)抽獎(jiǎng)效果
- jquery輸入數(shù)字隨機(jī)抽獎(jiǎng)特效的簡(jiǎn)單實(shí)現(xiàn)代碼
- jquery實(shí)現(xiàn)轉(zhuǎn)盤(pán)抽獎(jiǎng)功能
- jquery——九宮格大轉(zhuǎn)盤(pán)抽獎(jiǎng)實(shí)例
- jQuery+PHP實(shí)現(xiàn)的擲色子抽獎(jiǎng)游戲?qū)嵗?/a>
相關(guān)文章
Jquery工作常用實(shí)例 使用AJAX使網(wǎng)頁(yè)進(jìn)行異步更新
AJAX 通過(guò)在后臺(tái)與服務(wù)器交換少量數(shù)據(jù)的方式,允許網(wǎng)頁(yè)進(jìn)行異步更新。這意味著有可能在不重載整個(gè)頁(yè)面的情況下,對(duì)網(wǎng)頁(yè)的一部分進(jìn)行更新。2011-07-07簡(jiǎn)單的jquery拖拽排序效果實(shí)現(xiàn)代碼
寫(xiě)了簡(jiǎn)單的跟隨鼠標(biāo)移動(dòng)效果。這個(gè)拖拽排序的效果的區(qū)別在于: 運(yùn)用了插入insertBefore 和 insertAfter 的方法2011-09-09jquery判斷checkbox(復(fù)選框)是否被選中的代碼
現(xiàn)在很多朋友都喜歡使用jquery了,所以很多的表格判斷都是基于jquery的,但實(shí)現(xiàn)方法與javascript原生代碼不同,對(duì)于checkbox的判斷大家可以參考下。2010-10-10jQuery中extend函數(shù)簡(jiǎn)單用法示例
這篇文章主要介紹了jQuery中extend函數(shù)簡(jiǎn)單用法,結(jié)合實(shí)例形式簡(jiǎn)單分析了jQuery使用extend函數(shù)擴(kuò)展對(duì)象屬性的相關(guān)操作技巧,需要的朋友可以參考下2017-10-10jQuery實(shí)現(xiàn)TAB風(fēng)格的全國(guó)省份城市滑動(dòng)切換效果代碼
這篇文章主要介紹了jQuery實(shí)現(xiàn)TAB風(fēng)格的全國(guó)省份城市滑動(dòng)切換效果代碼,涉及jquery鼠標(biāo)mouseover事件及頁(yè)面元素遍歷的相關(guān)技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-08-08jQuery中創(chuàng)建實(shí)例與原型繼承揭秘
在普通情況下我們要用原生類(lèi)、或者自定義類(lèi)創(chuàng)建實(shí)例要用new運(yùn)算符,使構(gòu)造函數(shù)創(chuàng)建一個(gè)實(shí)例,并且實(shí)例繼承構(gòu)造器prototype上的所有公有方法2011-12-12jQuery實(shí)現(xiàn)給input綁定回車(chē)事件的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)給input綁定回車(chē)事件的方法,結(jié)合實(shí)例形式分析了2種常用的事件綁定操作技巧,需要的朋友可以參考下2017-02-02