javascript - Jquery callback function not working to redirect page -


how callback function on 2nd line redirect user after animation runs? want redirect link in href of 'nav li a'.

if leave callback "" animation works fine nothing (as expected). if put think work fails , of time breaks first line working @ all. i'm trying page slide in it's starting offscreen position on load (1st line). slide out first reload page (2nd line).

$('section').animate({"left":"0px"}, 450);  $('nav li a').click(function () { $('section').animate({ "left": "1000px"}, 1000, "");         return false;   });  

prevent anchors default action, store reference anchor callback animate() creates new scope, redirect :

$('section').animate({"left":"0px"}, 450);  $('nav li a').on('click', function(e) {      e.preventdefault();      var self = this;      $('section').animate({ "left": "1000px"}, 1000, function() {          window.location.href = self.href;     }); }); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -