九方格抽奖插件

自己编写的九方格抽奖插件九方格抽奖插件

参考网址http://demo.qpdiy.com/all/plugins/Lottery/lottery--horse3/h/index.html

关键代码:

 1 var num = 0; //当前点亮的灯

 2   var circle = 0; //至少转跑马灯的圈数

 3   var t; //定时器

 4   var len;//奖品个数

 5   function lightChange($prizes, changeClass, prizeArr, prizeNum){

 6       var self = this;

 7       len = $prizes.length;

 8 

 9       $prizes.removeClass(changeClass);

10       $prizes.eq(prizeArr[num]).addClass(changeClass);

11       if(num == len-1){

12         num = 0;

13         circle ++;

14       } else {

15         num ++;

16       }

17 

18       if(circle == 2 && num == prizeNum){

19         circle = 0;

20         clearTimeout(t);

21       } else {

22         t = setTimeout(function(){lightChange($prizes, changeClass, prizeArr, prizeNum)},300); 

23       }

24     }
View Code

 

你可能感兴趣的:(插件)