sayham-sjb
10/20/2017 - 5:16 AM

JavaScriptsetInterval()Method.js

JavaScriptsetInterval()Method #js #VS

var dtId;
function autoGenDt() {
    var date = new Date();
    document.getElementById("dtPnl").innerHTML = date;
}
function autoDtSrt() {
    if (dtId) {
        clearInterval(dtId);
    }
    dtId = setInterval(function () {
        autoGenDt();
    }, 1000);
}

function autoDtStp() {
    clearInterval(dtId);
}

function autoDtRst() {
    document.getElementById("dtPnl").innerHTML = 'Reset complete, hit start..';
    clearInterval(dtId);
}