web老虎机

2017-11-14  本文已影响0人  顺风飘千里
生成三个随机数
slotOne = Math.floor(Math.random() * (3 - 1 + 1)) + 1;
slotTwo = Math.floor(Math.random() * (3 - 1 + 1)) + 1;
slotThree = Math.floor(Math.random() * (3 - 1 + 1)) + 1;
检查随机数是否全部相等
if(slotOne===slotTwo&&slotTwo===slotThree){
      return slotOne;
    }else{
      return null;
    }
更新老虎机数字
$($(".slot")[0]).html(slotOne);
$($(".slot")[1]).html(slotTwo);
$($(".slot")[2]).html(slotThree);
根据不同的数字更新图片
$($('.slot')[0]).html('<img src = "' + images[slotOne-1] + '">');
$($('.slot')[1]).html('<img src = "' + images[slotTwo-1] + '">');
$($('.slot')[2]).html('<img src = "' + images[slotThree-1] + '">');
上一篇 下一篇

猜你喜欢

热点阅读