<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>特效时钟</title> </head> <body> <div id="myblock"></div> <script type="text/javascript"> function mytime(){ var time=new Date(); var hh=time.getHours(); var mm=time.getMinutes(); var ss=time.getSeconds(); document.getElementById("myblock").innerHTML="现在是"+hh+":"+mm+":"+ss; } var my=setInterval("mytime()",1000) </script> <input type="button" value="取消" onclick="javascript:clearInterval(my)"> </body> </html>