use .stop()

$(document).ready(function(){

        $("div#button1").click(function(){
                $("#box").stop().animate({
                        "margin-left" : "150px"
                });
        });
        $("div#button2").click(function(){
                $("#box").stop().animate({
                        "width" : "500px"
                });
        });

});



sundowatch wrote:
I wonna stop an animate function which hasn't been completed yet.

For example;

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">

$(document).ready(function(){

$("div#button1").click(function(){
$("#box").animate({
"margin-left" : "150px"
});
});
$("div#button2").click(function(){
$("#box").animate({
"width" : "500px"
});
});

});

</script>

I started button1 animation, If I click "button2","box" must stop
animate1 and start animate2.
How can I do this?

Reply via email to