【发布时间】:2011-08-06 16:06:13
【问题描述】:
我找到了这个脚本
$(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>
结果是这样的:
4236375205 seconds remaining! Something
768766798 seconds remaining! Something else
我有一个格式如下的日期 2011-10-29 10:05:00,我使用 <?php echo $date ?> 显示这个日期
我需要将 $date 传递给<tr id=,以便显示到该日期的剩余时间,但保持相同的格式 Y-m-d H:i:s 甚至 H:i:s 会很棒。
我刚刚检查完http://keith-wood.name/countdown.html 的 jQuery Countdown 插件,但它不适合我,因为我需要多个倒计时。
我希望这很清楚,您可以理解我的问题。 提前感谢,对不起我的英语
【问题讨论】: