您好,登錄后才能下訂單哦!
使用jQuery插件實現(xiàn)一個移動端的扭蛋機抽獎功能?針對這個問題,這篇文章詳細介紹了相對應(yī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>扭蛋機</title> <!--移動端版本兼容 --> <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"> <!--機器--> <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> <!--中獎掉落--> <div class="medon"><img src="images/mendong.png"/></div> <div class="zjdl "> <span></span> </div> </div> <!--中獎 獲得一等獎--> <div class="zonj_zezc none" id="jianpin_one"> <div class="jpzs aiqiyi tc_anima"> <em><img src="images/close.png"/></em> <h3> <b>恭喜你!<br>獲得一等獎!</b> </h3> </div></div> <!--中獎獲得二等獎--> <div class="zonj_zezc none" id="jianpin_two"> <div class="jpzs aiqiyi tc_anima"> <em><img src="images/close.png"/></em> <h3> <b>恭喜你!<br>獲得二等獎!</b> </h3> </div> </div> <!--中獎 獲得三等獎--> <div class="zonj_zezc none" id="jianpin_three"> <div class="jpzs aiqiyi tc_anima"> <em><img src="images/close.png"/></em> <h3> <b>恭喜你!<br>獲得三等獎!</b> </h3> </div> </div> <!--沒有中獎--> <div class="zonj_zezc none" id="jianpin_kong"> <div class="jpzs aiqiyi tc_anima"> <em><img src="images/close.png"/></em> <h3> 咦?沒有抽中? </h3> </div> </div> <!--積分不足--> <div class="zonj_zezc none" id="no_jifeng"> <div class="jpzs aiqiyi tc_anima"> <em><img src="images/close.png"/></em> <h3> 對不起,積分不足! </h3> </div> </div> <script> $(document).ready(function(e) { //一等獎 關(guān)閉 $("#jianpin_one em img").click(function(){ $("#jianpin_one").hide(); } ); //二等獎 關(guān)閉 $("#jianpin_two em img").click(function(){ $("#jianpin_two").hide(); } ); //三等獎 關(guān)閉 $("#jianpin_three em img").click(function(){ $("#jianpin_three").hide(); } ); //沒有中獎 關(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) //取消動畫 setTimeout(function (){ $(".zjdl").addClass("none").removeClass("dila_Y"); $(".wdjifen").html(score); $(".zjdl").children("span").removeAttr('class'); },2500) } }); </script> </body> </html>
關(guān)于使用jQuery插件實現(xiàn)一個移動端的扭蛋機抽獎功能問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注億速云行業(yè)資訊頻道了解更多相關(guān)知識。
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。