How to use the Stop method of the jquery animated animate
Animate syntax:
Copy CodeThe code is as follows:
$ (selector). Animate (Styles,speed,easing,callback)
Copy CodeThe code is as follows:
<!doctype html>
<meta charset= "UTF-8" >
<title>Testing</title>
<link rel= "stylesheet" href= "Css/reset.css" >
<script src= "Js/jquery.js" ></script>
<style>
. Wrap {
position:relative;
height:300px;
width:300px;
border:5px solid #FCF;
}
. Wrap Div {
Position:absolute;
left:0;top:0;
height:50px;
width:50px;
Background: #FA0;
}
</style>
<body>
<input type= "button" id= "BTN1" value= "Stop Current Animation" >
<input type= "button" id= "BTN2" value= "Stop all Animations" >
<input type= "button" id= "Btn3" value= "Stop all animations and reach the end" >
<div class= "Wrap" >
<div></div>
</div>
<script>
function MoveX () {
$ ('. Wrap div '). Animate ({' Left ': ' 250px '},1000). Animate ({' Left ': ' 0px '},1000);
} MoveX ();
$ (' #btn1 '). Click (function () {
$ ('. Wrap div '). Stop (); Stops the current animation and returns to the starting point along the way, pausing in the road if you click again during the return process
Clearinterval ();
})
$ (' #btn2 '). Click (function () {
$ ('. Wrap div '). Stop (true); Stop all animations go to the distance of the click Stop will directly reach the end, if the return process and then click, will be suspended in the road
})
$ (' #btn3 '). Click (function () {
$ ('. Wrap div '). Stop (True,true); Stop all animations, go to the distance of the click Stop will directly reach the end, if the return process and then click, will stop to at the beginning
})
. Stop ()//Stop current animation
. Stop (TRUE)//Stop all animations
. Stop (True,true)//Stop all animations and reach the end of animation
</script>
</body>
. Stop (); Stops the current animation and returns to the starting point along the way, pausing in the road if you click again during the return process
. Stop (true); Stop all animations go to the distance of the click Stop will directly reach the end, if the return process and then click, will be suspended in the road
. Stop (True,true); Stop all animations, go to the distance of the click Stop will directly reach the end, if the return process and then click, will stop to at the beginning
How to use the Stop method of the jquery animated animate