如果点一下暂停、点2下恢复该怎么写呢
ficapy
2014-08-09
3 回答
自己回答一下自己吧
<!doctype html>
<html lang="en">
<meta charset="UTF-8">
<body>
<input type="text" id="clock" size="35" />
<script language=javascript>
var int = [],count;
int.push(setInterval(clock,500))
function clock(){
var t = new Date;
document.getElementById("clock").value = t;
}
function control(){
console.log(int);
count = int.length;
if(count ==0){
int.push(setInterval(clock,500));
}else{
for(var b=0;b<int.length;b++){
clearInterval(int[b])
}
int.length = 0
}
}
</script>
<button onclick="control()">控制</button>
</body>
</html>
举报
0/150
提交
取消