分のカウントダウン

2112 ワード

<p id='headerNum'>00:20:00p>
    var hour = $('#headerNum').text().split(':')[0]
    var minute = $('#headerNum').text().split(':')[1]
    var second = $('#headerNum').text().split(':')[2]
    var settime = setInterval(mytime,1000);
    function mytime(){
        if(second <= 0 ){
            second = 60;
            minute--;                   
        }       
        second--;
        if(minute < 0){     
            clearInterval(settime);
            $('#headerNum').text('00:00:00');
            return;
        }
        $('#headerNum').text(hour + ':' + (minute<10?'0'+minute:minute) + ':' + (second<10?"0"+second:second))

    }