hilios / jQuery.countdown

The Final Countdown plugin for jQuery
http://hilios.github.io/jQuery.countdown/
MIT License
2.3k stars 720 forks source link

html() is ignored #314

Open OvalMedia opened 5 years ago

OvalMedia commented 5 years ago

I am using jquery-2.1.4. (Although 1.11.1 yielded the same result).

<div id="clock"></div>

jQuery(document).ready(function ($) {
   $('#clock').countdown('2020/10/10', function(event) {
        $(this).html(event.strftime('%D days %H:%M:%S'));
        console.log(event.strftime('%D days %H:%M:%S'));
    });
});

The html() function is completely ignored while console.log() works fine, the time gets logged every second as expected.

No errors in the console or anything.

It gets even weirder. For the fun of it I put in an alert into the function:

jQuery(document).ready(function ($) {
   $('#clock').countdown('2020/10/10', function(event) {
        $(this).html(event.strftime('%D days %H:%M:%S'));
        alert(event.strftime('%D days %H:%M:%S'));
    });
});

It doesn't matter what the alert displays but with each alert window #clock actually gets displayed and updated all of a sudden. Of course this is not a solution but maybe it helps find the issue?

Might be related: https://github.com/hilios/jQuery.countdown/issues/220

OvalMedia commented 5 years ago

I got it working by using a completely different element as the target. The html() function should not modifiy the countdown() element.