首页 > 代码库 > js实现简单点名/抽奖

js实现简单点名/抽奖

<body>
<div id="mainBox">
<div id="showResult"></div>
<div id="btnGroup">
<button onclick="start()">点击开始</button>
<button onclick="end()">停止</button>
</div>
</div>
<script>
var arr="洛靖斌,周尘子,申莉,刘善鑫,李娜,郑博仁,左鹏,文玉杰,刘芷默,李昭榕,张博文,江军,栗铭铭,张凯旋,邓旭峰,王健,马志伟,李妍姣,杨鑫平,金玉娇,王崇征,张利鑫,穆秋冰,史红岩,关兴莹";
var msg=arr.split(",");
var num=msg.length-1;
var timer;
console.log(msg);
function start(){
clearInterval(timer);
timer=setInterval(‘select()‘, 10);
}
function end(){
clearInterval(timer);
}
function select () {
document.getElementById("showResult").innerHTML=msg[GetRnd(0,num)];
}
function GetRnd(min,max){
return parseInt(Math.random()*(max-min+1));
}
</script>
</body>

js实现简单点名/抽奖