web老虎机

生成三个随机数
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] + '">');
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • FreeCodeCamp - Basic JavaScript 写在前面: 我曾经在进谷前刷过这一套题,不过当时只...
    付林恒阅读 16,531评论 5 28
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,991评论 19 139
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,523评论 25 708
  • [第三篇 KinectV2骨骼获取原理和获取方法及源代码] Kinect v2控制鼠标原理分析和源码(0积分下载)...
    狼之独步阅读 2,370评论 0 1
  • 深夜,寒风起,树叶作响,府中灯火明,却是鸦雀无声。 打破沉寂的是端坐正中的老者。 你说。 他将目光投向一个五大三粗...
    红雪阅读 250评论 0 0