Jquery multi-countdown .each() function

后端 未结 1 1005
無奈伤痛
無奈伤痛 2021-01-28 04:00

I\'m trying to make a multi-countdown on a page, which looks like :

相关标签:
1条回答
  • 2021-01-28 04:31
    $(document).ready(function(){  
      $('tr[id]').each(function () {
         var $this = $(this);
         var count = parseInt($this.attr("id"));
         countdown = setInterval(function(){
             $('.remain', $this).html(count + " seconds remaining!");
             if (count-- == 0) {
               //do something
               clearInterval(countdown);
             }
         }, 1000);
      });  
    });
    

    Try it here : http://jsfiddle.net/moeishaa/PwG45/

    0 讨论(0)
提交回复
热议问题