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,524評論 25 708
  • [第三篇 KinectV2骨骼獲取原理和獲取方法及源代碼] Kinect v2控制鼠標原理分析和源碼(0積分下載)...
    狼之獨步閱讀 2,370評論 0 1
  • 深夜,寒風起,樹葉作響,府中燈火明,卻是鴉雀無聲。 打破沉寂的是端坐正中的老者。 你說。 他將目光投向一個五大三粗...
    紅雪閱讀 250評論 0 0