I create a div that when is clicked it executes an jquery script, but the problem I have is that in the animation there is a link, when you click on the link the links is execute as well as the animation but it does not let the animation to end. Is there a way to let know Jquery that when the links its executed wait for the animation to end and then go to the link?
A:
You need to handle the link's click
event and record the click, then return false
to prevent the navigation.
Then when the animation finishes, check whether you've recorded a click, and, if so, set location.href
.
However, I don't recommend doing this. If a user clicked a link, he obviously wants to go to that page, and he's not interested in your animation.
SLaks
2010-05-21 04:10:11
A:
You can use the callback param for the animate function:
$('a').click(function(){
$(this).animate({}, 500, function() { location.href = $(this).attr('href') });
return false;
});
This will execute the animation when the link is clicked and will go to the url once the animation has completed.
spad3s
2010-05-21 16:19:34