日期循环+stop

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>自动变换星期</title>
<script>
window.onload = function (){
var i=0;
var oStop=document.getElementById("stop");
var timer = setInterval(function() {
var a=document.getElementById("week");
i++;
if(i>=50) {clearInterval(timer);}
a.value=="星期六"?a.value="星期五":a.value="星期六";
},1000);

oStop.onclick=function(){
i=50;
}
}
</script>
</head>
<body>
<form>
<input type="text" value="星期五" id="week" />
<input type="button" value="stop" id="stop" />
</form>
</body>
</html>

posted on 2014-08-27 11:00  moliwanzi  阅读(83)  评论(0编辑  收藏  举报

导航