My timer

Timer

by santhucool007

HTML

<div id="timer"></div>
<input type="button" value="click me" id="btn">

JavaScript

$(document).ready(function () {
    var count = 10;

    $("#btn").click(function () {
        clickme(count);
    });

    //Make initial font size

    function formatTime(seconds) {
        var h = Math.floor(seconds / 3600),
            m = Math.floor(seconds / 60) % 60,
            s = seconds % 60;
        if (h < 10) h = "0" + h;
        if (m < 10) m = "0" + m;
        if (s < 10) s = "0" + s;
        return m + ":" + s;
    }
    
    var counter;
    function clickme() {
        $('#timer').css({
            'color': 'black',
                'font-size': '200%'
        });
        $("#timer").css("display", "block");
        count = 10;
        counter = setInterval(timer, 1000);
    }

    function timer() {
        count--;
        if (count < 0) {
            $("#timer").css("display", "none");
            return clearInterval(counter);
        }
        if (count < 6) {
            $('#timer').css({
                'color': 'red',
                    'font-size': '200%'
            });
        }

        $('#timer').html(formatTime(count));
    }

});