I’m using jquery animate to slide a div off the page, this works fine but i would like to change the animate to:
- only happen once(because if somebody double clicks it, the div comes back), and
- wait for animation to finish before the href is followed.
This is the code that performs the div slide:
$(".choose").click(function(event) {
var $contentDiv = $("#content");
$contentDiv.stop().animate({
marginLeft: parseInt($contentDiv.css('marginLeft'),10) == 0 ?
$contentDiv.outerWidth() : 0
});
});
You can call
event.preventDefault()to prevent the default click action, and then do a manual redirect by settinglocation.hrefafter the animation using a callback…