js动态显示指定的时间
<p id="timeShow">17:0:50</p> <script> setInterval("time()", 1000); function time() { var time=$("#timeShow").html(); var timeArr= new Array(); //定义一数组 timeArr=time.split(":"); //字符分割 sec=Number(timeArr[2])+Number(1); var d = new Date() d.setHours(timeArr[0],timeArr[1],sec); var hours=d.getHours(); var minutes=d.getMinutes(); var sec=d.getSeconds(); var timeStr=hours+":"+minutes+":"+sec; $("#timeShow").html(timeStr); } </script>