js倒计时

<script>
var now=1425440050;
// 订单倒计时
$(function() {
function count_down(sec) {
if(sec<=0) return ‘-‘;
var s = sec;
var left_s = s % 60;
var m = Math.floor(s / 60);
var left_m = m % 60;
var h = Math.floor(m / 60);
var left_h = h % 24;
var d = Math.floor(h / 24);

var ret = [];
d && ret.push(‘<span class=”d”>’, d, ‘</span>天’);
left_h && ret.push(‘<span class=”h”>’, left_h, ‘</span>时’);
left_m && ret.push(‘<span class=”m”>’, left_m, ‘</span>分’);
left_s && ret.push(‘<span class=”s”>’, left_s, ‘</span>秒’);

return ret.join(”);
}

now += 3;

$(‘.orderForm-statusTip em’).each(function() {
this.sec = parseInt($(this).attr(‘time’), 10);
this.innerHTML = count_down(this.sec – now);
});
setInterval(function() {++now;
$(‘.orderForm-statusTip em’).each(function() {
this.innerHTML = count_down(this.sec – now);
});
}, 1000);
});
</script>
<p class=”orderForm-statusTip”>自动清除倒计时:<br /><em time=”1425440050″></em><p>