I wrote this jQuery code, but when i tried to stop the animated elements while it is returning to its original position (using Callback function),it didn’t responded, but it become slower !! .
I am using jquery-1.6.4 version
<script type="text/javascript">
$(function () {
$("#right").click(function () {
$(".theDiv0").animate({ left: "800px" }, 2000, "swing", returnToLeft);
$(".theDiv1").animate({ left: "800px" }, 2000, "linear", returnToLeft);
});
function returnToLeft() {
$(".theDiv0").animate({ left: "10px" }, 2000, "swing");
$(".theDiv1").animate({ left: "10px" }, 2000, "linear");
}
$("#stop").click(function () {
$(".theDiv0,.theDiv1").stop();
});
});
</script>
Any Suggestion/Solution ??
Try using
.stop(true)See the docs for further informations. If I’m right, this should really stop the animation.