Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php jQueryMultipleConcountDown_Php_Jquery_Countdown - Fatal编程技术网

Php jQueryMultipleConcountDown

Php jQueryMultipleConcountDown,php,jquery,countdown,Php,Jquery,Countdown,我找到了这个脚本 $(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!")

我找到了这个脚本

$(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);
  });  
});
在HTML上,此代码为:

<table>  
  <tr id="4236377487">
    <td class="remain"></td>
    <td>Something</td>
  </tr>
  <tr id="768769080">
    <td class="remain"></td>
    <td>Something else</td>
  </tr>
</table>
我有一个日期,格式如下2011-10-29 10:05:00,我用

我需要的是将$date传递给
试试这个

$(document).ready(function(){  
  $('tr[id]').each(function () {
     var $this = $(this);
     var count = parseInt($this.attr("id"));
     countdown = setInterval(function(){
         var curDate = (new Date()).getMilliseconds();
         var newDate = new Date(count-curDate);
         var dateString = newDate.getHours() + ":" + newDate.getMinutes() + ":" + newDate.getSeconds();
         $('.remain', $this).html(dateString + " seconds remaining!");
         if (count-- == 0) {
           //do something
           clearInterval(countdown);
         }
     }, 1000);
  });  
});
试试这个

$(document).ready(function(){  
  $('tr[id]').each(function () {
     var $this = $(this);
     var count = parseInt($this.attr("id"));
     countdown = setInterval(function(){
         var curDate = (new Date()).getMilliseconds();
         var newDate = new Date(count-curDate);
         var dateString = newDate.getHours() + ":" + newDate.getMinutes() + ":" + newDate.getSeconds();
         $('.remain', $this).html(dateString + " seconds remaining!");
         if (count-- == 0) {
           //do something
           clearInterval(countdown);
         }
     }, 1000);
  });  
});