gpt4 book ai didi

javascript随机var数组图像

转载 作者:行者123 更新时间:2023-11-28 07:49:20 25 4
gpt4 key购买 nike

我有以下代码:

<script src="js/jquery-1.8.1.min.js" type="text/javascript"></script>
<script src="js/html5placeholder.jquery.js" type="text/javascript"></script>

<!--[if IE]><script type="text/javascript" src="js/excanvas.js"> </script><![endif]-->
<script src="js/general.js" type="text/javascript"></script>
<script language="JavaScript">
function foo(n)
{
var a = 123456789;
a = a.toString();
var result = "";
e = document.getElementById("kq");
for(i = 0; i < a.length; i++)
{
result += "<img src=\"number/a"+a[i]+".png\" />";

}
e.innerHTML = result;

}


var solanMax = 10;
var n = 0;
function foo2()
{
solan = 0;
result = "";
result += "<img src=\"number/a"+n+".png\" />";
if(n == 9)
n -= 9;
if(n >= 0)
n++;
e0 = document.getElementById("kq0");
e1 = document.getElementById("kq1");
e2 = document.getElementById("kq2");
e3 = document.getElementById("kq3");
e4 = document.getElementById("kq4");
e5 = document.getElementById("kq5");
e6 = document.getElementById("kq6");
e7 = document.getElementById("kq7");
e8 = document.getElementById("kq8");
e9 = document.getElementById("kq9");

e0.innerHTML = result;
e1.innerHTML = result;
e2.innerHTML = result;
e3.innerHTML = result;
e4.innerHTML = result;
e5.innerHTML = result;
e6.innerHTML = result;
e7.innerHTML = result;
e8.innerHTML = result;
e9.innerHTML = result;
solan ++;
T = setTimeout('foo2('+n+')',solan);
}
function Stop(){
setTimeout('clearTimeout(T)',1000);

}
</script>
<input type=button value='Lottery Number Picker' onClick="foo2();">
<span id="kq0" class=a1>Result</span>
<span id="kq1" class=a1>Result</span>
<span id="kq2" class=a1>Result</span>
<span id="kq3" class=a1>Result</span>
<span id="kq4" class=a1>Result</span>
<span id="kq5" class=a1>Result</span>
<span id="kq6" class=a1>Result</span>
<span id="kq7" class=a1>Result</span>
<span id="kq8" class=a1>Result</span>
<span id="kq9" class=a1>Result</span>
<br>
<input type=button value='Stop' onClick="Stop();">

我想按“停止”按钮,所有预设的返回次数都相同演示:http://group-cast.com/Binhchon/test.php非常感谢,我是越南人,所以英语有点不好

最佳答案

我不确定你到底想要什么。但是当您为彩票生成数字时,我假设您希望这些数字是随机的。您可以添加一个新函数 getImageForRandomNum 并更改 foo2 函数,如下所示...

function getImageForRandomNum(){
var n = Math.floor((Math.random() * 10));
result = "<img src=\"number/a"+n+".png\" />";
return result;
}

function foo2()
{
e0 = document.getElementById("kq0");
e1 = document.getElementById("kq1");
e2 = document.getElementById("kq2");
e3 = document.getElementById("kq3");
e4 = document.getElementById("kq4");
e5 = document.getElementById("kq5");
e6 = document.getElementById("kq6");
e7 = document.getElementById("kq7");
e8 = document.getElementById("kq8");
e9 = document.getElementById("kq9");

e0.innerHTML = getImageForRandomNum();
e1.innerHTML = getImageForRandomNum();
e2.innerHTML = getImageForRandomNum();
e3.innerHTML = getImageForRandomNum();
e4.innerHTML = getImageForRandomNum();
e5.innerHTML = getImageForRandomNum();
e6.innerHTML = getImageForRandomNum();
e7.innerHTML = getImageForRandomNum();
e8.innerHTML = getImageForRandomNum();
e9.innerHTML = getImageForRandomNum();
solan ++;
T = setTimeout('foo2('+n+')',solan);
}

关于javascript随机var数组图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27043348/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com