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 checkbox 勾選的bug問(wèn)題解決方案與分析
本文首先由一個(gè)在項(xiàng)目中遇到的jquery checkbox 勾選的bug的解決方案,引申出jQuery中attr()和prop()的差異分析,非常的實(shí)用,需要的小伙伴快來(lái)研究下吧2014-11-11
jquery 面包屑導(dǎo)航 具體實(shí)現(xiàn)
jquery 面包屑導(dǎo)航 具體實(shí)現(xiàn),需要的朋友可以參考一下2013-06-06
Jquery 模板數(shù)據(jù)綁定插件的使用方法詳解
本篇文章是對(duì)在Jquery中模板數(shù)據(jù)綁定插件的使用方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-07-07
jQuery實(shí)現(xiàn)選中彈出窗口選擇框內(nèi)容后賦值給文本框的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)選中彈出窗口選擇框內(nèi)容后賦值給文本框的方法,涉及jQuery響應(yīng)鼠標(biāo)事件動(dòng)態(tài)操作頁(yè)面元素屬性的相關(guān)技巧,需要的朋友可以參考下2015-11-11
jQuery實(shí)現(xiàn)下拉菜單的實(shí)例代碼
本文通過(guò)實(shí)例代碼給大家講解了jQuery實(shí)現(xiàn)下拉菜單效果,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-06-06
jQuery實(shí)現(xiàn)菜單欄導(dǎo)航效果
這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)簡(jiǎn)單菜單欄導(dǎo)航效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-08-08
jquery+css3問(wèn)卷答題卡翻頁(yè)動(dòng)畫(huà)效果示例
本篇文章主要介紹了jquery css3問(wèn)卷答題卡翻頁(yè)動(dòng)畫(huà)效果,具有一定的參考價(jià)值,有需要的朋友可以了解一下。2016-10-10
基于JQuery實(shí)現(xiàn)的跑馬燈效果(文字無(wú)縫向上翻動(dòng))
本篇文章分享了如何實(shí)現(xiàn)文字無(wú)縫向上翻動(dòng)效果的示例代碼。代碼清晰明了,可直接下載使用。有興趣的朋友可以看下2016-12-12

