jquery animated animate underlying principle guessing

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.