<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
#first{
width: 200px;
height: 200px;
border: 1px solid red;
border-radius: 50%;
text-align: center;
line-height: 200px;
color: red;
margin: 0 auto;
}
#bm{
width: 80px;
height: 30px;
display: block;
margin: 0 auto;
margin-top: 20px;
}
</style>
</head>
<body>
<div id="first">准备抽取学员</div>
<button id="bm">开始</button>
<script>
var _first=document.querySelector("#first");
var _bm=document.querySelector("#bm");
var id;
_bm.onclick=function(){
var a=_bm.innerText;
if(a=="开始"){
_bm.innerText="结束";
id=setInterval(function(){
var random=Math.floor(Math.random() * 35);
if(random<10){
random="0"+random;
}
_first.innerText=`web202206b${random}`;
},100)
}else{
_bm.innerText="开始";
clearInterval(id);
}
}
</script>
</body>
</html>
js随机点名
最新推荐文章于 2023-01-14 16:59:29 发布