手机端转盘抽奖代码分享_javascript技巧

WBOY
Release: 2016-05-16 15:39:45
Original
1589 people have browsed it

演示效果如下:

不废话了,直接给大家贴代码了。

html部分

4元 6元 8元 11元
13元 手机端转盘抽奖代码分享_javascript技巧 40元
80元 125元
250元 400元
1000元 iphone6 谢谢惠顾 500元
Copy after login

css部分,由于做的这个转盘是手机端的,采用的响应式布局

.turntableWap{ padding:1rem; background:url(../images/zpTabBg.jpg) no-repeat center; background-size:100% 100%;} .turntableWap table{ width:100%;} .turntableWap table td{ vertical-align:middle; text-align:center; background-color:#ecd295;} .turntableWap table td img{ width:100%; } .turntableWap table td.even{background-color:#f6e8c5} .turntableWap table td.active{ background-color:#ed9351;}
Copy after login

js部分

$(".turntableWap .table").css({"height":$(".turntableWap .table").width()});//做响应式布局,外table是等宽高 var isdo = true; $(".zpBtn").on("click",function(){ var num = 13;//后台传入的奖品 var rotaNum = 14;//奖品数量 var count = -1;//高亮显示,旋转特效 var jishi = 0;//计时时间段 var speed = 50;//快速速度 var speedSlow = 200;//慢速速度 choujiang()//抽奖方法调用,在此处做判断调用choujiang(),并给num值 function choujiang(){ if(isdo){ isdo=false; $(".turntableWap").css({"background-image":"url(../images/1.gif)"}) var c = setInterval(function(){ if(count >12){ count = -1; } count = count+1; jishi = jishi+1; $(".turntableWap td").removeClass("active"); $(".turntableWap td[tag="+count+"]").addClass("active"); if(jishi>rotaNum*2){ clearInterval(c); c = setInterval(function(){ count = count+1; jishi = jishi+1; $(".turntableWap td").removeClass("active"); $(".turntableWap td[tag="+count+"]").addClass("active"); if(jishi>num+rotaNum*2){ clearInterval(c); $(".turntableWap").css({"background-image":"url(../images/zpTabBg.jpg)"}) isdo = true; var jp = $(".turntableWap td[tag="+count+"]").find("img").attr("alt") alert("恭喜您获取"+jp) } },speedSlow) } },speed) }else{ return; } } })
Copy after login

以上就是本文给大家分享的手机端转盘抽奖代码分享,希望大家喜欢。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!