1

Alright, I maybe a bit to strung out from caffeine atm to figure this one out on my own, but i'm trying to figure out how to redirect visitors to a page after splash image has faded.

$(document).ready(
function 
() 
{$('.wrapper a img').hover(
        function ()
        {
            $(this).stop().animate({ opacity: .4 } , 200);
            settimeout(function(){window.location = '/blog';}, 200); 
        }
)});

It's not working and is drving me a bit nutt

4

1 回答 1

3

.animate允许您定义将在动画完成时调用的回调:

$(this).stop().animate({ opacity: .4 } , 200, "swing", function() {
    window.location = '/blog';
});

第三个参数 ( "swing") 只是该参数的默认值。

相同的另一种语法是

.animate({ opacity: .4 }, {
    duration: 200,
    complete: function() { window.location = '/blog'; }
);

最后,还有一种方法是使用.promise当元素的动画队列为空(即所有动画都已结束)时将完成的 a:

.animate({ opacity: .4 } , 200)
.promise().done(function() { window.location = '/blog'; });
于 2013-07-03T21:09:25.363 回答