代码展示:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
div{
width: 200px;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
#wrapper{
width: 200px;
height: 200px;
border-radius: 100px;
line-height: 200px;
text-align: center;
border: 1px solid red;
background-color: lightgrey;
color: red;
font-size: 23px;
font-weight: 800;
}
button{
margin-top: 10px;
width: 60px;
height: 30px;
font-size: 20px;
}
</style>
</head>
<body>
<div>
<div id="wrapper">
等待抽取
</div>
<button onclick="action(this)">开始</button>
</div>
<script>
b=document.getElementById("wrapper");
function action(tag){
if(tag.innerHTML=="开始"){
tag.innerHTML="结束";
id=setInterval(function change(){
a=Math.floor(Math.random()*26);//0-25
//当数值小于10时,给数值前面补0
if(a<10){
a="0"+a;
}
b.innerHTML=`18081010${a}`;
},100)
}else{
tag.innerHTML="开始";
clearInterval(id);
}
}
</script>
</body>
</html>
结果展示:
如果想改变其中的内容,自己不会,可以找我哦!!