<div id="box">亲,准备好点名了吗?</div> <input type="button" value="开始点名" id="bt" onClick="doit()"/>
var namelist = ["张三", "李四", "王五", "贺六", "孙九", "赵十", "刘一"]; var mytime = null; function doit() { if (mytime == null) { $("#bt").val("停止点名"); show(); } else { $("#bt").val("开始点名"); clearTimeout(mytime); mytime = null; } } function show() { var box = window.document.getElementById("box"); var num = Math.floor((Math.random() * 100000)) % namelist.length; box.innerHTML = namelist[num]; mytime = setTimeout("show()", 1); }