Klock

Kountdown JS Plugin

Instalation

https://cdn.jsdelivr.net/gh/kelvinbiffi/Countdown@1.1/kountdown.js
    
    
        <body>

            ...
            ...

            <!-- Colar script antes de fechar a tag body-->
            <script src="https://cdn.jsdelivr.net/gh/kelvinbiffi/Countdown@1.1/kountdown.js"></script>
        </body>
    
    
    

Usage



    <div data-kountdown="DATE|POSITION|CALLBACK"></div>


OR



    // Interval to wait Plugin exists
    var waitKountdown = setInterval(function () {
    if (Kountdown) {
        clearInterval(waitKountdown);
        
        // Usege to specific element
        var element = document.querySelector('selector of element');
        var kountdown = new Kountdown(element, '2047-11-08T00:00:00', 'END');
        kountdown.create(function (date) {
            console.log(date);
        });
    }
    }, 100);


Examples

Black Friday



    <section class="blackfriday">
        <h3>Black Friday</h3>
        <div></div>
    </section>

    <script>
        var waitKountdown = setInterval(function () {
        if (Kountdown) {
            clearInterval(waitKountdown);
            
            // Usege to specific element
            var element = document.querySelector('.blackfriday div');
            var kountdown = new Kountdown(element, '2021-11-26T00:00:00', 'BEGIN');
            kountdown.create(function (date) {
                console.log(date);
            });
        }
        }, 100);
    </script>


Christimas



    <script>
        window.handleSeconds = function (data) {
            console.log(data);
        };
    </script>

    <section class="christimas">
        <h3>Christmas</h3>
        <div data-kountdown="2021-12-25T00:00:00|END|handleSeconds"></div>
    </section>


New year



    <section class="new-year">
        <h3>New year</h3>
        <div data-kountdown="2021-12-31T00:00:00"></div>
    </section>