:왜 지연()이 작동하지 않습니까? <a href="http://jsfiddle.net/9gvrj/" rel="nofollow">this example</a>에서
$('#click').click(function() {
$('#delay').delay(2000).css('background-color', '#c30000');
});
왜 delay()
호출은 css()
호출을 지연하지 않는 이유는 무엇입니까?
:왜 지연()이 작동하지 않습니까? <a href="http://jsfiddle.net/9gvrj/" rel="nofollow">this example</a>에서
$('#click').click(function() {
$('#delay').delay(2000).css('background-color', '#c30000');
});
왜 delay()
호출은 css()
호출을 지연하지 않는 이유는 무엇입니까?
체크 아웃 http://api.jquery.com/delay/과에서
$(document).ready(function() {
$('#click').click(function() {
$('#delay').delay(2000).queue(function() {
$(this).css('background-color', '#c30000');
});
});
});
를 사용하여 자바 스크립트의에서는 setTimeout() :
setTimeout(function() {
$('#delay').css('background-color', '#c30000');
}, 2000);
http://api.jquery.com/queue/documentation :
.delay() 메소드 이 지연 최고 ~사이3210 대기중인 jQuery 효과. 제한적이기 때문에 예를 들어 지연을 취소하는 방법을 제공하지 않습니다 .delay()는 JavaScript의 기본 setTimeout 함수를 대체하지 않으며 특정 사용 사례에 더 적합 할 수 있습니다.
기본적으로 시나리오에서는 기본적으로 타임 아웃이 지연 효과보다 효과적이지 않으므로 더 나은 방법입니다.
delay()
은 jQuery effects에만 해당됩니다.
대신 기본 setTimeout
호출을 사용하십시오.
GMTA -하지만 너무 느리다. http://jsfiddle.net/nrabinowitz/ZWcud/ – nrabinowitz