stop method in jQuery with examples

1. stop() method id used to stop the currently running animation on the matched elements.
2. When the stop() method is called on an element, the currently running animation is stopped immediately. 

Example 1 :

        <script type="text/javascript" src=""> 
        <script type="text/javascript">
            $(document).ready(function () {
                $("#start").click(function () {
                    $("#myDiv").animate({ width: "500px" }, 5000);
                $("#stop").click(function () {
                $("#reset").click(function () {
                    $("#myDiv").animate({ width: "100px" }, 500);
        <div id="myDiv"></div><br/>
        <input type="button" id="start" Value="Start"/>
        <input type="button" id="stop" Value="Stop"/>
        <input type="button" id="reset" Value="Reset"/>
Demo :

In the above example, we have used stop() method. We have created a div element and applied required CSS to it. We have also created buttons to demonstrate how stop() method works. On click of "Start" button we are calling animation() method on div element, which manipulates its CSS like an animation effect.
As soon as we click on "Stop" button the animation is stopped.


Post a Comment