<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>随机抽奖</title> <style> .box{width:600px;height:500px;margin:0 auto;border:dashed #ccc 2px;} button{width:120px;height:40px;border-radius: 10px;margin:30px auto;font-size: 26px;display: block;} span{width:300px;height:300px;background:#ffff99;display: block;margin:0 auto;border-radius:100%;text-align: center;font-size:30px;line-height:300px;} </style> <script> var a1=["林惊羽","曾书书","碧瑶","张小凡","无崖子","鬼王"]; var times; function star(){ var index=parseInt(Math.random()*a1.length); var x=a1[index]; var s=document.getElementById("show"); s.innerHTML=x; } function start(){ times=setInterval(star,40); } function end(){ clearInterval(times); } </script> </head> <body> <div class="box"> <span id="show">等待抽奖</span> <button οnclick="start()">开始抽奖</button> <button οnclick="end()">结束抽奖</button> </div> </body> </html>
JavaScript随机抽奖
最新推荐文章于 2023-12-06 10:30:00 发布