jQuery preventDefault stops rest of code working
Posted
by Tim
on Stack Overflow
See other posts from Stack Overflow
or by Tim
Published on 2010-04-24T20:05:28Z
Indexed on
2010/04/25
8:33 UTC
Read the original article
Hit count: 397
I have this code where I am using jQuery to navigate to the next page, because I want some effects to take place before that happens. The problem is, that everything after the prevent.Default(); doesn't seem to work!
$("a").click(function(event){
event.preventDefault();
$(".content-center").animate({height: "0px"}, 500);
navigate($(this).attr('href'));
});
I need things to happen in that order, so that the animation happens and once it's complete - load the next page...
Does anyone have any ideas? Many thanks in advance?
Tim
Updated code (moves to new page but no animation occurs) ---
$("a").click(function(event){
event.preventDefault();
var driver = $(this).attr('href');
$(".content-center").animate({
height: "0px"
}, 500, function(){
navigate(driver);
});
});
see: http://bit.ly/aOeYgE
Many thanks for your help!!
© Stack Overflow or respective owner