Home >>jQuery Tutorial >jQuery stop() Method

jQuery stop() Method

jQuery stop() Method

jQuery stop() method in jQuery is used to stops the currently running animation for the selected elements.

Syntax:
$(selector).stop(stopAll,goToEnd)

Parameter Values

Parameter Description
stopAll It is Optional parameter used to specify a Boolean value whether or not to stop the queued animations as well.
goToEnd It is Optional parameter used to specify a Boolean value whether or not to complete all animations immediately
Here is an Example of jQuery stop() Method:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script> 
$(document).ready(function(){
$("#start").click(function(){
$("#stop1").animate({height: 300}, 3000);
$("#stop1").animate({width: 300}, 3000);
});
$("#stop").click(function(){
$("#stop1").stop();
});
});
</script> 
</head>
<body>
<p>
<button id="start">Start Animation</button>
<button id="stop">Stop Current Animation</button>
</p>
<div id="stop1" style="background:purple;height:100px;width:100px"></div>
</body>
</html>

Output:


No Sidebar ads