Usage and Difference of jq stop of and: is of: animated Detailed Explanation of of

  • 2021-07-21 05:56:16
  • OfStack

stop(true,true):

Indicates that the animation of the matching element is stopped and jumps to the end state, emptying the queue of unfinished animations. Commonly used to "solve the cursor move in and out of the animation effect caused by too fast and cursor action is not 1" problem!

jQuery stop () method

The jQuery stop () method is used to stop animations or effects until they are complete.

The stop () method works with all jQuery effect functions, including sliding, fade-in and fade-out, and custom animations.

Grammar

$(selector). stop (stopAll, goToEnd); The optional stopAll parameter specifies whether the animation queue should be cleared. The default is false, which stops only active animations, allowing any queued animations to be executed backwards.

The optional goToEnd parameter specifies whether the current animation is completed immediately. The default is false.

Therefore, by default, stop () clears the current animation specified on the selected element.

The following example demonstrates the stop () method without parameters:


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

: is (": animated"): animated is the jQ selector that selects all animation elements

Determining whether an element is in an animated state is often used when "one button is clicked up/down continuously, only responding to the first click action of the user".


if(!$("#lunbolist li").is(":animated")){ 
      $("#lunbolist li").filter(".on").hide(); 
      $("#lunbolist li").eq(currentindex).fadeIn(100).addClass("on").siblings().removeClass("on"); 
      $(this).addClass("on").siblings().removeClass("on"); 
    } 


Related articles: