Home >>jQuery Tutorial >jQuery finish() Method

jQuery finish() Method

jQuery finish() Method

jQuery finish() method in jQuery is an inbuilt method which is used to completes all animations for the selected elements and stop the animations running at the present time.

Syntax:
$(selector).finish(queueName)

Parameter Values

Parameter Description
queueName It is Optional parameter to stop animations and stop animations of the que to the specifies name
Here is an example of jQuery finish() 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(){
$("#anBox").animate({height: 300}, 3000);
$("#anBox").animate({width: 300}, 3000);
});
$("#complete").click(function(){
$("#anBox").finish();
});
});
</script> 
</head>
<body>
<p>
<button id="start">Start</button>
<button id="complete">Finish</button>
</p>
<div id="anBox" style="background:#98bf21;height:100px;width:100px"></div>
 </body>
</html>

Output: