我只是想听听,如果将时间设置为 0 毫秒的 setInterval 存在问题?会不会有性能问题?拥有例如 1000 毫秒会更好吗?
我有这个脚本:
var countdown_id = setInterval(function() {
var now = (new Date()).getTime()-(2*60*60*1000);
;
$('.product').each(function() {
var elm = $(this).attr('id');
var prod_id = $("#"+elm+" #hidden-"+elm).val();
var expires = $('#date-end-' + prod_id).val()*1000;
var seconds_remaining = Math.round((expires - now)/1000);
var hours = FormatNumberLength(Math.floor(seconds_remaining/(60*60)), 2);
var sec_remaining = seconds_remaining-(hours*60*60);
var minutes = FormatNumberLength(Math.floor(sec_remaining/60), 2);
var sec_remaining2 = sec_remaining-(minutes*60);
var seconds = FormatNumberLength(sec_remaining2, 2);
var timestr = hours + ":" + minutes + ":"+seconds;
if (expires) {
if (seconds_remaining > 0) {
$('#'+elm+' .time_left div').text(timestr);
}
else {
$(this).hide();
}
}
$('#'+elm+' .time_left div').text(timestr);
});
}, 0);
提前致谢!