我在我的網站上有一些圖像,並且這個代碼我想隱藏它們,改變顯示的圖像並顯示它們,但是新圖像立即顯示。我不知道該怎麼辦。.delay()函數在attr()函數上不起作用
這是JavaScript:
$(document).ready(function() {
$('.show').click(function() {
$(this).removeClass("show").addClass("clickedShow");
$('.show').animate({opacity: 0}, 1000);
$(this).delay(1000).animate({opacity: 0}, 1000);
$(this).animate({opacity: 1}, 1000).attr("src", "pic2.png");
$('.show').delay(1000).animate({opacity: 1}, 1000).attr("src", "pic2.png");
});
});
這將解決您的問題:http://stackoverflow.com/questions/2807127/jquery-delay-doesnt-delay-attr-in-the-queue – Amrendra 2013-03-15 09:35:55