第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 javascript/html 中用新字符串替換字符串?

如何在 javascript/html 中用新字符串替換字符串?

哆啦的時光機(jī) 2023-12-11 10:31:51
我有一臺最近制作的老虎機(jī),但我想讓它看起來更好一點。https://codesandbox.io/s/slot-machine-xip7x?file=/index.html:0-1480(抱歉,我在將代碼復(fù)制并粘貼到代碼示例中時遇到問題:( 我對此很陌生地點。)這是該代碼的結(jié)果:https://xip7x.csb.app/每次滾動時,屏幕左側(cè)都會出現(xiàn)一個項目符號點,結(jié)果位于中間。當(dāng)您滾動多次時,新結(jié)果只會添加到已有結(jié)果中。任何人都可以做到這一點,這樣就沒有要點,并且每次滾動時它都會替換之前的滾動條并僅顯示新的滾動條,因此頁面上始終只有一個滾動條。我是編碼新手,很想完成這個項目。如果有人能幫助我并解釋他們做了什么,我會很高興。謝謝!
查看完整描述

1 回答

?
叮當(dāng)貓咪

TA貢獻(xiàn)1776條經(jīng)驗 獲得超12個贊

這是你想要的嗎?


 var firstx = ["X", "O", "L", "L"];

      var secondx = ["X", "O", "L", "L"];

      var thirdx = ["X", "O", "L", "L"];


      function randIndex() {

        var randIndex1 = Math.floor(Math.random() * 4);

        var randIndex2 = Math.floor(Math.random() * 4);

        var randIndex3 = Math.floor(Math.random() * 4);

        var first = firstx[randIndex1];

        var second = secondx[randIndex2];

        var third = thirdx[randIndex3];

        var btn = document.getElementById("btn");

        var sent = document.getElementById("sent");

        var result = first + " " + second + " " + third;

        if (result == "X X X") {

          alert("CONGRATULATIONS! YOU WIN!");

        }


        sent.innerHTML ="<li>" + result + "</li>";

        btn.innerText = "Roll Again";

      }

  font-family: helvetica;

        text-align: center;

        -webkit-text-fill-color: black;

      }


      body {

        background-color: lightcoral;

      }

 <!DOCTYPE html>

<html>

  <head>

    <title>Slot Machine</title>

    <meta charset="UTF-8" />

  </head>


  <body>

 <h1>Slot Machine</h1>

    <p>

      Welcome to the slot machine! To play, click the "Roll" button. If you get

      three X's, YOU WIN! Have fun and Enjoy your new gambling addiction!

    </p>

    <br />

    <button id="btn" onclick="randIndex();">

      Roll

    </button>


    <ul id="sent"></ul>


    <br /><br />

    <hr />

    <br /><br />

      </body>

</html>


查看完整回答
反對 回復(fù) 2023-12-11
  • 1 回答
  • 0 關(guān)注
  • 134 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號