clearInterval()之后怎么再回复定时器呀
clearInterval()之后怎么再回复定时器呀?
clearInterval()之后怎么再回复定时器呀?
2016-07-04
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>计时器</title>
</head>
<body>
<script type="text/javascript">
function clock()
{
var time = new Date();
document.getElementById("clock").value=time;
}
function start()
{
i = setInterval("clock()",1000);
}
var i = setInterval("clock()",1000);
</script>
<form>
<input type="text" id="clock" size="50px" />
<input type="button" value="start" onclick="start()" />
<input type="button" value="stop" onclick="clearInterval(i)" />
</form>
</body>
</html>举报