JS简单的计时器

//显示学习计时器
var hour = 0, minute = 0, second = 0;
var t = 0;
var flag1;
function studyTime()
{
    hour=parseInt(t/60/60);
    minute=parseInt(t/60%60);
    second=parseInt(t%60);
    document.getElementById('SECOND').innerHTML=second;
    document.getElementById('HOUR').innerHTML=hour;
    document.getElementById('MINUTE').innerHTML=minute;
    t = t + 1;
    flag1 = setTimeout("studyTime()", 1000);            
}
//终止学习计时器
function stopTime()
{
    clearTimeout(flag1);
}

你可能感兴趣的:(function)