stop ([clearQueue, gotoEnd]), méthode

La description

le stop( [clearQueue, gotoEnd ]) La méthode arrête toutes les animations en cours d'exécution sur tous les éléments spécifiés.

Syntaxe

Voici la syntaxe simple pour utiliser cette méthode -

selector.stop( [clearQueue], [gotoEnd] ) ;

Paramètres

Voici la description de tous les paramètres utilisés par cette méthode -

  • clearQueue- Il s'agit d'un paramètre booléen facultatif. Lorsqu'il est défini sur true, efface la file d'attente d'animation, arrêtant efficacement toutes les animations en file d'attente.

  • gotoEnd- Il s'agit d'un paramètre booléen facultatif. Une valeur booléenne (true / false) qui, lorsqu'elle est définie sur true, entraîne la fin immédiate de l'animation en cours de lecture, y compris la réinitialisation des styles d'origine à l'affichage et au masquage et l'appel de la fonction de rappel.

Exemple

Voici un exemple simple montrant l'utilisation de cette méthode -

<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
		
      <script type = "text/javascript" language = "javascript">
   
         $(document).ready(function() {

            $("#go").click(function(){
               $(".target").animate({left: '+=100px'}, 2000);
            });

            $("#stop").click(function(){
               $(".target").stop();
            });

            $("#back").click(function(){
               $(".target").animate({left: '-=100px'}, 2000);
            });
				
         });
      </script>
		
      <style>
         p {background-color:#bca; width:250px; border:1px solid green;}   
         div{position: absolute; left: 50px; top:300px;}
      </style>
   </head>
	
   <body>
      <p>Click on any of the following buttons:</p>
		
      <button id = "go"> GO</button>
      <button id = "stop"> STOP </button>
      <button id = "back"> BACK </button>

      <div class = "target">
         <img src = "/jquery/images/jquery.jpg" alt = "jQuery" />
      </div>
   </body>
</html>

Cela produira le résultat suivant -

jquery-effects.htm