<!DOCTYPE html>
<html lang="en">
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>双色球</title>
</head>
<style>
ul li {
background-color: red;
border: solid 1px #000;
border-radius: 50%;
width: 50px;
height: 50px;
float: left;
color: #000;
list-style: none;
line-height: 50px;
text-align: center;
}
span {
width: 50px;
height: 50px;
border-radius: 50%;
border: solid 1px #000;
float: left;
background-color: royalblue;
color: #000;
line-height: 50px;
text-align: center;
}
</style>
<body>
<div>
<ul id="ul">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<span id="spani"></span>
</div>
<button id="cxc_1">开始</button>
<button id="cxc_2">清空</button>
</body>
<script>
var lii = ul.getElementsByTagName('li');
cxc_1.onclick = function() {
cxc_a = setInterval(function() {
for (var i = 0; i < lii.length; i++) {
lii[i].innerHTML = Math.floor(Math.random() * 30);
}
spani.innerHTML = Math.floor(Math.random() * 20);
clearInterval(cxc_a)
}, 100);
}
cxc_2.onclick = function() {
for (var i = 0; i > lii.length; i++) {
console.log(lii[i]);
lii[i].innerHTML = '';
}
spani.innerHTML = '';
}
</script>
</html>
10-06
1868
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-22