首页 > 代码库 > 日期循环+stop

日期循环+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.valuehttp://www.mamicode.com/=="星期六"?a.value="http://www.mamicode.com/星期五":a.value="http://www.mamicode.com/星期六";
},1000);

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

日期循环+stop