<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<link rel="stylesheet" href="lib/zTree_v3-master/css/demo.css">
<link rel="stylesheet" href="lib/zTree_v3-master/css/zTreeStyle/zTreeStyle.css">
<script>
var object= null;
var nameArr = ["1","2","3","4","5","6","7","8"];//名字
var thinkArr = ["唱歌","说绕口令","真心话","大冒险"];//惩罚
function dianming(obj){
var cpdom = document.getElementById('cp');
if(obj.getAttribute('data') == "start"){
obj.setAttribute('data',"qwe");
obj.innerHTML = "停止";
object = setInterval(function(){
cpdom.value = nameArr[parseInt(Math.random()*nameArr.length)]+"->"+thinkArr[parseInt(Math.random()*thinkArr.length)];
},10);
}else{
clearInterval(object);
obj.innerHTML = "开始";
obj.setAttribute('data',"start");
}
}
</script>
</head>
<body>
<button onClick="dianming(this)" data="start">点名</button>
<input id="cp" type="text">
</iframe>
</body>
</html>