我想成立時間對網頁進行自動去,所以我有id屬性的html代碼:如何在自己的html網頁上設置時間功能?
<div id="demo">
</div>
和JS的功能,這使得時間用戶:
function tellTime() {
var now = new Date();
var theHr = now.getHours();
var theMin = now.getMinutes();
document.write("time: " + theHr + ":" + theMin);
}
document.getElementById("demo").innerHTML = tellTime();
所以當頁面重新加載它似乎時間但用戶muss重新加載頁面,以查看當前時間。
我們怎樣才能設置Function,它不需要重新加載看什麼是當前時間?
感謝
避免鏈接到W3Schools的。鏈接到質量更好的在線資源(如MDN或W3)要好得多。 – BenM