<!doctype html> <html> <head> <meta charset="utf-8"> <title>js获取获取当前时间</title> <script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script> <style> * { margin: 0; padding: 0; } .time { font-size: 48px } </style> </head> <body> <div class="time"></div> <script> function get10(i) { if (i < 10) { i = "0" + i }; return i } setInterval(function() { var d = new Date() var t = d.getHours() var m = d.getMinutes() var s = d.getSeconds() $(".time").html(get10(t) + ":" + get10(m) + " <font color='#808080' style='font-size:30px'>" + get10(s) + "</font>") }, 100) </script> </body> </html>