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
Post a Comment