When using the Animate () method in jquery, if you imagine a general program, execute a notconsistent of the conditional statement variable at the end of the program:
HTML code:
<div id= "DV" >
<div id= "D2" ></div>
</div>
<button id= "Move" > Mobile </button>
css:div{
Display:none;
position:relative;
left:0px;
}
JS Code:
var disp=0;
$ ("#move"). Click (function () {
if (disp==0) {
The next animation is not allowed to start until the animation execution is complete, so change the value of disp
Disp=1;
$ ("#dv"). Animate ({
LEFT:20,
},{
duration:2000
});
}
In general, when the program executes here, the above program has been executed, but the animation is not so, change the value of disp here,
Disp=0;
The value of the disp is changed before the animation is executed, because the animation statements are waiting before the program finishes executing. So it's not going to change the judging criteria.
});
jquery animated animate underlying principle guessing