时钟操作js---显示时间点
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body onload="startTime()"> <div id="timetxt"></div> <script> function startTime(){ var today = new Date(); var h = today.getHours(); var m = today.getMinutes(); var s = today.getSeconds(); m = checkTime(m); s = checkTime(s); document.getElementById("timetxt").innerHTML = h + ":" + m + ":" + s; t = setTimeout(function(){ startTime(); },1000); } function checkTime(i){ if(i<10){ i = "0"+i; } return i; } </script> </body> </html>