- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <html>
- <head>
- </head>
- <body>
- k686绿色软件 - http://www.k686.com
- <script>
- function countDown( maxtime,fn )
- {
- var timer = setInterval(function()
- {
- if(maxtime>=0){
- minutes = Math.floor(maxtime/60);
- seconds = Math.floor(maxtime%60);
- msg = "距离结束还有"+minutes+"分"+seconds+"秒";
- fn( msg );
- if(maxtime == 5*60) alert('注意,还有5分钟!');
- --maxtime;
- }
- else{
- clearInterval( timer );
- fn("时间到,结束!");
- }
- }, 1000);
- }
- </script>
- <div id="timer1" style="color:red"></div>
- <div id="timer2" style="color:red"></div>
- <script>
- countDown( 6,function( msg )
- {
- document.getElementById('timer1').innerHTML = msg;
- });
- countDown( 6000,function( msg )
- {
- document.getElementById('timer2').innerHTML = msg;
- })
- </script>
- </body>
- </html>
js倒计时代码 支持同一页面多个倒计时代码
最新推荐文章于 2021-07-01 20:29:26 发布