<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://cdn.bootcss.com/jquery/1.8.3/jquery.js"></script> <title>计时器</title> </head> <body> <div id="time"></div> <script type="text/javascript"> var timer = 0; setTimer(); function setTimer(){ timer++; var hh = parseInt(timer/3600); var ii = parseInt((timer/60)%60); var ss = parseInt(timer%60); if(hh>99)return; if(hh<10)hh = "0"+hh; if(ii<10)ii = "0"+ii; if(ss<10)ss = "0"+ss; $("#time").html(hh+":"+ii+":"+ss); t = setTimeout("setTimer()",1000); } </script> </body> </html>