<!DOCTYPE html> <html> <head> <title>倒计时</title> <meta charset="utf-8"> </head> <script type="text/javascript"> var c = 0; var t; function onChange(){ document.getElementById('myText').value = c; c += 1; t = setTimeout("onChange()", 1000); } function onStop () { c = 0; clearTimeout(t); document.getElementById("myText").value = c; } </script> <body> <input type="button" value="点击按钮,进行倒计时" onclick="onChange()"> <input type="text" id="myText"> <input type="button" value="点击按钮,停止倒计时" onclick="onStop()"> </br> <p>点击按钮,将从0 开始进行循环 + 1</p> </body> </html>