模拟抽奖 时间:2020-05-11 人气:0 模拟抽奖-51windows.Net <script LANGUAGE="JavaScript"> var alldata = "51windows,blueidea,csdn,google,baidu,msn,qq,cctv,microsoft,adobe" //抽奖的姓名,以,为分隔 var alldataarr = alldata.split(",") var num = alldataarr.length-1 var timer function change(){ document.getElementById("oknum").value = alldataarr[GetRnd(0,num)]; } function start(){ clearInterval(timer); timer = setInterval('change()',50); //50(毫秒)为变换间隔,越小变换的越快 } function ok(){ clearInterval(timer); } function GetRnd(min,max){ return parseInt(Math.random()*(max-min+1)); } </script> 模拟抽奖: 开始(S) 停止(O) [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] 加载全部内容