我希望時間每秒重置,以便時鐘成爲運行時鐘。我是javascript noob,我無法在任何地方找到任何解決方案。使時鐘運行
<!--
var currentDate = new Date()
var day = currentDate.getDate()
var month = currentDate.getMonth() + 1
var year = currentDate.getFullYear()
document.write("<b>" + day + "/" + month + "/" + year + "</b>")
//-->
<!--
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
var seconds = currentTime.getSeconds()
if (minutes < 10)
minutes = "0" + minutes
if (seconds < 10)
seconds = "0" + seconds
document.write(hours + ":" + minutes + ":" + seconds)
嘗試'window.setInterval' – rab
你需要的是每秒鐘運行它。所以嘗試使用setInterval(function(){//你的代碼在這裏},1000); –