jQuery Tutorial Tutorials - jQuery .stop()

jQuery .stop()

The .stop() method in jQuery is used to stop the currently-running animation.

jQuery .stop() syntax

.stop([clearQueue][,jumpToEnd]);
Parameter Type Description
clearQueue Boolean whether clear the queue.Default false
jumpToEnd Boolean whether to complete the current animation immediately.Default false
queue Function The name of the queue.

jQuery .stop() Examples

example

stop the currently-running animation.

$("#clickme").click(function(){
    $('#box').stop();
});

example

click the STOP button to stop animation where it's currently positioned
HTML

<button id="go">Go</button> <button id="stop">STOP!</button>
<div id="block"></div>
// Start animation
$("#go").click(function(){
    $("#block").animate({left: '+=200px'}, 2000);
});
// Stop animation
$("#stop").click(function(){
    $("#block").stop();
});

Try now

Date:2019-08-30 02:35:51 From:www.Lautturi.com author:Lautturi