<script type="text/javascript">
var btn = document.querySelector(".top button");
var lock = true;
btn.onclick = function() {
if (lock) {
btn.innerHTML = '停止点名';
times = setInterval( function (){
var spans = document.querySelectorAll(".content span");
for(var i =0;i<spans.length;i++){
spans[i].index = i;
spans[i].className = "";
}
num = Math.floor(Math.random()*i);
spans[num].className = "active";
console.log("num",num);
},500);
if(document.querySelector('.active') != null){
document.querySelector('.active').remove();
}
} else {
btn.innerHTML = '开始';
clearInterval(times);
}
lock = !lock;
}
script>