首页 新闻 会员 周边

Jquery求解

0
悬赏园豆:10 [已解决问题] 解决于 2015-11-17 19:01

当点击结束的时候无法对应到上面的数值,,,为什么

var arr = [0,1,2,3,4,5,6,7];
        var index = arr[Math.floor((Math.random() * 8))];
        var index;
        lottery.prize = index;
        if ( index == 0) {                         
           var text=999;       
          $("#yuan").html(text);  
                        }
        if (index == 1) {
           var text=300;
           $("#yuan").html(text);
                        }
        if (index == 2) {                       
            var text=888;
            $("#yuan").html(text);
                        }
        if ( index == 3) {                           
            var text=200;
            $("#yuan").html(text);
                        }
        if ( index == 4) {                            
            var text=777;
            $("#yuan").html(text); 
                        }
        if ( index== 5) {                          
            var text=500;
            $("#yuan").html(text);
                        }
        if ( index== 6) {                        
            var text=666;
            $("#yuan").html(text);
                        }
        if (index == 7) {                          
            var text=400;
            $("#yuan").html(text);
                        }    

是不是写法上有误,,求解

像风一样自由~~~的主页 像风一样自由~~~ | 初学一级 | 园豆:48
提问于:2015-11-17 11:34
< >
分享
最佳答案
0

应该是你的 index 对不上,调试下,看看 每个元素的 index 是多少。你试下 var arr = [0,1,2,3,5,6,7,8];

收获园豆:10
明Lam | 小虾三级 |园豆:615 | 2015-11-17 14:49

已经试过了,,,没用,http://hbdev1.jingyubank.com/html/game/Earning/index.html直接给你贴地址了,,,帮看一眼

像风一样自由~~~ | 园豆:48 (初学一级) | 2015-11-17 14:59

手机端

像风一样自由~~~ | 园豆:48 (初学一级) | 2015-11-17 15:01

@像风一样自由~~~: 在你的函数

showPrize:function(){
setTimeout(function (){
$('.present').fadeIn();
},1000);
},

改为:

showPrize:function(){

var index=$(".active")[0].className.substr(10, 1);

if ( index == 1) { 
var text=999; 
$("#yuan").text(text); 
}
if (index == 2) {
var text=300;
$("#yuan").text(text); 
}
if (index == 3) { 
var text=888;
$("#yuan").text(text); 
}
if ( index == 4) { 
var text=200;
$("#yuan").text(text); 
}
if ( index == 5) { 
var text=777;
$("#yuan").text(text); 
}
if ( index== 6) { 
var text=500;
$("#yuan").text(text); 
}
if ( index== 7) { 
var text=666;
$("#yuan").text(text); 
}
if (index ==8) { 
var text=400;
$("#yuan").text(text); 
}


setTimeout(function (){
$('.present').fadeIn();
},1000);
},

明Lam | 园豆:615 (小虾三级) | 2015-11-17 18:03

你的函数

//降速
downSpeed:function () {
if (lottery.index == 8) {
lottery.cycle += 1;
}
if (lottery.cycle > lottery.times - 1 && lottery.speed < 400) {
lottery.speed += 20;
lottery.stop();
lottery.start();
}

if (lottery.cycle > lottery.times && lottery.index == lottery.prize) {
lottery.stop();
lottery.showPrize();

}

},

 

根本就没进去过,我觉得你应该是点停止的时候调用的。你应该全部再改下,点停止的时候降速到0时就OK了。

明Lam | 园豆:615 (小虾三级) | 2015-11-17 18:07

@啊~小明: 特别感谢,,,已经解决,,就像你说的一样

像风一样自由~~~ | 园豆:48 (初学一级) | 2015-11-17 19:02

@啊~小明: 能不能让它在点击【停止】后光圈减速1秒内停止呢

像风一样自由~~~ | 园豆:48 (初学一级) | 2015-11-17 20:26

@像风一样自由~~~: 可以的,你想想怎麼触发降速到停止就可以了

明Lam | 园豆:615 (小虾三级) | 2015-11-18 08:03

@啊~小明: 

downSpeed:function () {
        if (lottery.index == 8) {
            lottery.cycle += 1;
        }
        if (lottery.cycle > lottery.times - 1 && lottery.speed < 400) {
            lottery.speed += 20;
            lottery.stop();
            lottery.start();
        }
 
        if (lottery.cycle > lottery.times && lottery.index == lottery.prize) {
            lottery.stop();
            lottery.showPrize();         
        }
 
    },

如何让它速度降下来呢,,,调用这个没有效果,,,是写的 不对吗

像风一样自由~~~ | 园豆:48 (初学一级) | 2015-11-18 09:14
其他回答(3)
0

0~7吧

茂茂 | 园豆:2892 (老鸟四级) | 2015-11-17 11:39

木有用

支持(0) 反对(0) 像风一样自由~~~ | 园豆:48 (初学一级) | 2015-11-17 14:33
0

lottery 是个什么东西。没有定义啊.记得引入jquery.

Mountains | 园豆:241 (菜鸟二级) | 2015-11-17 12:04

九宫图转盘,,一切正常,,就是值对不上

支持(0) 反对(0) 像风一样自由~~~ | 园豆:48 (初学一级) | 2015-11-17 14:31
0

在图上面,你的五是海豚

如此低调的男人 | 园豆:842 (小虾三级) | 2015-11-17 14:10

大哥,,那是鲸鱼仔

支持(0) 反对(0) 像风一样自由~~~ | 园豆:48 (初学一级) | 2015-11-17 14:31

@像风一样自由~~~: 好吧,鲸鱼仔,按照你的图展示那是不是应该是1,2,3,6,9,8,7,4???

支持(0) 反对(0) 如此低调的男人 | 园豆:842 (小虾三级) | 2015-11-17 15:02

@夕边日落: http://hbdev1.jingyubank.com/html/game/Earning/index.html你看下这个

支持(0) 反对(0) 像风一样自由~~~ | 园豆:48 (初学一级) | 2015-11-17 15:08

手机端调试

支持(0) 反对(0) 像风一样自由~~~ | 园豆:48 (初学一级) | 2015-11-17 15:09
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册