js简易倒计时,好用。
<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> </head> <body> <div> <span id="m"></span>分 <span id="s"></span>秒</div> <script> var m = 1; //设置分 var s = 5; //设置秒 function showtime(){ document.getElementById('m').innerHTML = m; document.getElementById('s').innerHTML = s; s = s-1; if(s==0){ m = m -1; s = 60 } if(m==0){ // window.location='http://www.ewceo.com';//倒计时结束跳转到www.ewceo.com } if(m<0 && s==60){ //当时间为0分1秒时,暂停 clearInterval(settime); } } clearInterval(settime); var settime = setInterval(function(){ showtime(); },1000); </script> </body> </html>