html代码
<input type&#61;"button" value&#61;"开始" onclick&#61;"strars()"/>
<input type&#61;"button" value&#61;"停止" onclick&#61;"stops()"/>
<h1>10h1>
js代码
var hh&#61;document.getElementsByTagName("h1")[0];
// console.log(hh);var timer&#61;null;function strars(){var n&#61;10;if(timer!&#61;null){//如果我还没点开始就已经在倒计时时return false;}timer&#61;setInterval(function(){if(n&#61;&#61;0){cleaN();return false;}hh.innerHTML&#61;--n;},1000)}function cleaN(){clearInterval(timer);alert("倒计时结束");timer&#61;null;}function stops(){cleaN();}