jQuery 1 minute countdown with milliseconds and callback

后端 未结 2 1597
既然无缘
既然无缘 2021-01-16 14:48

I\'m trying to figure out a way to display a simple countdown that displays 1:00:00 whereby 1 = minutes, 00 = seconds, and 00 = milliseconds.

I\'ve found loads of jQ

2条回答
  •  北海茫月
    2021-01-16 15:04

    Hi guys I have developed a code for my self use the following code counter for 20 seconds

    var _STOP =0;
    
    var value=1999;
    
    function settimer()
    
    {
    var svalue = value.toString();
    
    if(svalue.length  == 3)
    
        svalue = '0'+svalue;
    else if(svalue.length  == 2)
        svalue = '00'+svalue;
    else if(svalue.length  == 1)
        svalue = '000'+svalue;
    else if(value == 0)
        svalue = '0000';
    document.getElementById('cn1').innerHTML = svalue[0];
    document.getElementById('cn2').innerHTML = svalue[1];
    document.getElementById('cn3').innerHTML = svalue[2];
    document.getElementById('cn4').innerHTML = svalue[3];   
    value--;
    
    if (_STOP==0 && value>=0) setTimeout("settimer();", 10);
    }
    
    setTimeout("settimer()", 10);
    

提交回复
热议问题