有没有办法在 az 之间创建一个不断变化的字母表来出现

像这样但对于字母表:


<p id="result"></p> <!-- this is code for random num gen ,I need something like this for alphabet.-->

    <script>

      var intrvl = setInterval(numbFunction, 500); //repeat function after 1.5 seconds(1500 ms)


      function numbFunction() {

        var x = Math.floor(Math.random() * 10 + 1); //return a random no. between 1 to 10

        document.getElementById("result").innerHTML = x;

      }

    </script>


阿晨1998
浏览 110回答 3
3回答

慕莱坞森

setInterval(function(){document.getElementById('result').innerHTML = String.fromCharCode(Math.floor(Math.random() * 25) + 97);}, 500);利用字符代码排序

摇曳的蔷薇

var intrvl = setInterval(numbFunction, 500);function numbFunction() {&nbsp; var characters = 'abcdefghijklmnopqrstuvwxyz';&nbsp; var charactersLength = characters.length;&nbsp; var x = Math.floor(Math.random() * charactersLength + 1);&nbsp; document.getElementById("result").innerHTML = characters[x]}<p id="result"></p>

狐的传说

setInterval(randomGen, 500);function randomGen() {&nbsp; const alphabet = "abcdefghijklmnopqrstuvwxyz"&nbsp; const random = alphabet[Math.floor(Math.random() *&nbsp; &nbsp; &nbsp; alphabet.length)];&nbsp; document.getElementById("rand").innerHTML = random;}<p id="rand"></p>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript