<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<button id="start">开始</button>
<button id="end">结束</button>
<h4 id="txt">开来抽奖吧</h4>
<script>
var list = ['张世杰', '盘驻华', '黎庆洪', '陈波将', '杨静接', '等东营'];
var start = document.getElementById('start');
var end = document.getElementById('end');
var txt = document.getElementById('txt');
var timmer;
start.onclick = function() {
clearInterval(timmer);
timmer = setInterval(function() {
txt.innerHTML = list[parseInt(Math.random() * list.length)];
}, 50)
}
end.onclick = function() {
clearInterval(timmer);
}
</script>
</body>
</html>
JavaScript笔记——简易版抽奖
最新推荐文章于 2023-05-10 17:24:33 发布