<html> <head> <meta charset="utf-8"> <title>测试计时器</title> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> var closer = setInterval(closeFunc, 1000); var l = 24*60*60*1000; function closeFunc(){ if(l > 0){ $("#ul").prepend(‘<li>温馨提示,咨询‘+readableFormat(l)+‘后关闭</li>‘); l = l-1000; }else{ // 关闭咨询 $("#ul").prepend(‘<li>温馨提示,咨询已关闭</li>‘); } } function readableFormat(l) { var s = ‘‘; var day = Math.floor(l / (1000 * 60 * 60 * 24)); var day_ = l % (1000 * 60 * 60 * 24); var hour = Math.floor(day_ / (1000 * 60 * 60)); var hour_ = day_ % (1000 * 60 * 60); var minute = Math.floor(hour_ / (1000 * 60)); var minute_ = hour_ % (1000 * 60); var second = Math.floor(minute_ / 1000); var second_ = minute_ % 1000; if (day != 0) { s += day + ‘天‘; } if (hour != 0) { s += hour + ‘小时‘; } if (minute != 0) { s += minute + ‘分‘; } s += second + ‘秒‘; return s; } </script> </head> <body> <ul id="ul"> </ul> </body> </html> </body> </html>
时间: 2024-10-28 03:20:58