jQuery Stop

The jQuery stop() method is used to stop animations or effects before it is finished.


jQuery .stop() Method



The .stop() method is used to halt ongoing animations or effects immediately before they finish. It applies to:


  • Sliding effects.slideDown(), .slideUp(), .slideToggle()
  • Fading effects .fadeIn(), .fadeOut(), .fadeToggle(), .fadeTo()
  • Custom animations.animate({})


Syntax:


$(selector).stop(stopAll, goToEnd);


Parameters:

  • stopAll (optional):

true clears the animation queue.

false (default) keeps queued animations.

  • goToEnd (optional):

true jumps to the final state of the current animation.

false (default) leaves it where it is.


So, by default, the stop() method kills the current animation being performed on the selected element.


The following example demonstrates the stop() method, with no parameters:

Example
<script>
$(document).ready(function(){
$("#startBtn").click(function(){
$("#box").animate({width: "400px"}, 3000);
});

$("#stopBtn").click(function(){
$("#box").stop();
});
});
</script>

Try it yourself


Whereisstuff is simple learing platform for beginer to advance level to improve there skills in technologies.we will provide all material free of cost.you can write a code in runkit workspace and we provide some extrac features also, you agree to have read and accepted our terms of use, cookie and privacy policy.
© Copyright 2024 www.whereisstuff.com. All rights reserved. Developed by whereisstuff Tech.