3 回答
TA贡献1810条经验 获得超4个赞
setInterval(function(){
document.getElementById('result').innerHTML = String.fromCharCode(Math.floor(Math.random() * 25) + 97);
}, 500);
利用字符代码排序
TA贡献1793条经验 获得超6个赞
var intrvl = setInterval(numbFunction, 500);
function numbFunction() {
var characters = 'abcdefghijklmnopqrstuvwxyz';
var charactersLength = characters.length;
var x = Math.floor(Math.random() * charactersLength + 1);
document.getElementById("result").innerHTML = characters[x]
}
<p id="result"></p>
TA贡献1804条经验 获得超3个赞
setInterval(randomGen, 500);
function randomGen() {
const alphabet = "abcdefghijklmnopqrstuvwxyz"
const random = alphabet[Math.floor(Math.random() * alphabet.length)];
document.getElementById("rand").innerHTML = random;
}
<p id="rand"></p>
添加回答
举报