当前位置:编程学习 > JS >>

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);           
}www.zzzyk.com
//终止学习计时器
function stopTime()
{
    clearTimeout(flag1);
}
作者:pamchen
补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,