是否有相當於在jQuery的1.4.2 setTimeout
和clearTimeout
功能....我發現這個前它使用的jQuery 1.3.2 ..的jQuery 1.4.2等效setTimeout和clearTimeout
var alerttimer = window.setTimeout(function() {
$alert.trigger('click');
}, 3000);
$alert.animate({height: $alert.css('line-height') || '50px'}, 200)
.click(function() {
window.clearTimeout(alerttimer);
$alert.animate({height: '0'}, 200);
});
請注意.delay()可能不會每5秒發生一次。事實上,由於執行時間的原因,它很可能會以稍大的間隔發生。 'repeat()'中的代碼需要時間來執行,然後設置延遲。它的工作原理,但它不會像setInterval() – 2010-07-19 18:11:36
@Ryan:你就在那裏。但是,無論如何,由於'UI隊列','ecma-/javascript'中的計時器並不準確。例如'setTimeout()'的原因是,在特定時間後添加一些代碼到'UI隊列'中。它並不贊同立即執行。 – jAndy 2010-07-19 19:40:16