感谢您的支持,我会继续努力的!
打开微信扫一扫,即可进行扫码打赏哦
点我查看本站打赏源码!
Powered by RUNCODEX.COM,学的不仅是技术,更是梦想!!!
<div id="result"></div><div style="clear:both; float:none"></div>
<div id="control">
<div id="num">0</div>
<input type="button" id="btnStart" value="开始" onclick="Start(this)" />
</div>
xxxxxxxxxx
var arrData = [], timerID = 0;
<!--随机的范围-->
for(var i = 1; i <=33; i++){
arrData[i - 1] = i;
}
function $(id){
return document.getElementById(id);
function Start(btn){
if(timerID > 0){
clearInterval(timerID);
timerID = 0;
if(arrData.length < 1){
alert("没有数据了!");
return;
if(btn.value == "开始"){
timerID = setInterval(function(){
$("num").index = parseInt(Math.random() * (arrData.length));
$("num").innerHTML = arrData[$("num").index];
}, 30);
btn.value = "暂停";
}else{
var div = document.createElement("div");
div.innerHTML = $("num").innerHTML;
$("result").appendChild(div);
arrData.splice($("num").index, 1);
btn.value = "开始";
window.onload = function(){
$("btnStart").focus();
};
html, body{
padding:0px; margin:0px; font-size:12px;
body{
margin:50px;
#result{
height:20px; margin-bottom:10px;
#result div{
float:left; border:1px solid #006699; color:#c00; width:24px; height:20px; line-height:20px;
margin-right:15px; text-align:center;
#control div{
float:left; width:24px; height:20px; line-height:20px; border:1px solid #008800; color:#c00;
margin-right:20px; text-align:center;