最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jquery Countdown on finish Callback - Stack Overflow

programmeradmin1浏览0评论

This plugin will show real time countdown which will show on the webpage.

I read documentation on.finish callback on the Official website.

What I try to do is that if the timer finish counting, it will hide span#limit.

This is the link:

.countdown/documentation.html

This is my Code :

HTML :

<span id="limit">
    <input type="hidden" name="limit" value="<?php echo $dataproduct['limit']; ?>" />
</span>

jQuery :

var data = $("input[name=limit]").val();

    $("#limit").countdown(data, function(event) {
    $(this).text(event.strftime('%D days %H:%M:%S'));
       .on('finish.countdown', function() {
           $(this).hide();
       )};
    });

it will show countdown like this on the webpage :

01 days 19:40:00

until

00 days 00:00:00

The problem was this span did not hide just like I try to do.

What's wrong with my code? Callback? Wrong syntax?

This plugin will show real time countdown which will show on the webpage.

I read documentation on.finish callback on the Official website.

What I try to do is that if the timer finish counting, it will hide span#limit.

This is the link:

http://hilios.github.io/jQuery.countdown/documentation.html

This is my Code :

HTML :

<span id="limit">
    <input type="hidden" name="limit" value="<?php echo $dataproduct['limit']; ?>" />
</span>

jQuery :

var data = $("input[name=limit]").val();

    $("#limit").countdown(data, function(event) {
    $(this).text(event.strftime('%D days %H:%M:%S'));
       .on('finish.countdown', function() {
           $(this).hide();
       )};
    });

it will show countdown like this on the webpage :

01 days 19:40:00

until

00 days 00:00:00

The problem was this span did not hide just like I try to do.

What's wrong with my code? Callback? Wrong syntax?

Share Improve this question edited Apr 11, 2016 at 20:27 halfer 20.4k19 gold badges109 silver badges202 bronze badges asked Jul 2, 2015 at 11:00 Ching ChingChing Ching 2171 gold badge5 silver badges15 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

Try this : As per doucument you have provide, you need to call .on('finish.countdown' after closing bracket of .countdown() function. And your code will work as expected.

 var data = $("input[name=limit]").val();

   $("#limit").countdown("2015-07-02 19:40:00", function(event)                        
   {
       $(this).text(event.strftime('%D days %H:%M:%S'));

    }).on('finish.countdown', function() {
           $(this).hide();
    });

JSFiddle Demo

NOTE: Please change the date input as per your convinient so that you can see countdown to bee zero in short time.

发布评论

评论列表(0)

  1. 暂无评论