In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to realize the lucky draw of Nine Palace Lattice by jquery. It is very detailed and has certain reference value. Friends who are interested must finish reading it.
The method to realize the lucky draw by jquery is as follows: 1, create the code displayed at the front end; 2, realize the lucky draw by jquery code "$(" # lottery a ") .click (function () {...}").
This article operating environment: windows7 system, jquery3.2.1 version, DELL G3 computer
An example of lottery draw for jquery-- Nine Palace turntable
First, the pictures used
Second, the code is as follows, focusing on the js part
JQuery # lottery {width:570px;height:510px;margin:0px auto;border:4px solid # ba1809;} # lottery table {background-color:yellow;} # lottery table td {position:relative;width:190px;height:170px;text-align:center;color:#333;font-index:-999} # lottery table td img {display:block;width:190px;height:170px;} # lottery table td a {width:190px;height:170px;display:block;text-decoration:none Background:url (images/lottery1.jpg) no-repeat top center;} # lottery table td a:hover {background-image:url (images/lottery2.jpg);} # lottery table td.active .mask {display:block;} .mask {width:100%; height:100%; position:absolute; left:0; top:0; background:url (images/mask.png) no-repeat; display:none;}
Var lottery= {index:-1, / / which position is currently rotated to, the starting position count:0, / / how many positions are there in total timer:0, / / ID of setTimeout Use clearTimeout to clear speed:20, / / initial rotation speed times:0, / / rotation times cycle:50, / / basic rotation times: that is, at least how many times do you need to rotate before entering the lottery prize:-1, / / the winning position init:function (id) {if ($("#" + id). Find (".lottery-unit") .length > 0) {$lottery = $("#" + id) $units = $lottery.find (".lottery-unit"); this.obj = $lottery; this.count = $units.length; $lottery.find (".lottery-unit-" + this.index) .addClass ("active");}, roll:function () {var index = this.index; var count = this.count; var lottery = this.obj; $(lottery) .find (".lottery-unit-" + index) .removeClass ("active") Index + = 1; if (index > count-1) {index= 0;}; $(lottery). Find (".lottery-unit-" + index) .addClass ("active"); this.index=index; return false;}, stop:function (index) {this.prize=index; return false;}}; function roll () {lottery.times + = 1; lottery.roll () / / the rotation process calls the roll method of lottery. Here is the first call to initialize if (lottery.times > lottery.cycle+10 & & lottery.prize==lottery.index) {clearTimeout (lottery.timer); lottery.prize=-1; lottery.times=0; click=false;} else {if (lottery.times lottery.cycle+10 & & ((lottery.prize==0 & & lottery.index==7) | | lottery.prize==lottery.index+1)) {lottery.speed + = 110 } else {lottery.speed + = 20;}} if (lottery.speed
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 225
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.