js之动态时钟源代码
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>js动态时钟</title> <script> function clock() { var d = new Date(); var h = d.getHours(); var m = d.getMinutes(); var s = d.getSeconds(); var hms = h + ":" + m + ":" + s; document.getElementById("clock").innerHTML=hms; setTimeout("clock()", 1000); } </script> </head> <body onload="clock()"> <h1 id="clock"></h1> </body> </html>