JQuery Callback method

Source: Internet
Author: User

The Callback function executes after the current animation 100% is complete.

Problems with JQuery animations

Many jQuery functions involve animations. These functions may use speed or duration as an optional parameter.

Example:$ ("P"). Hide ("slow")

the speed or duration parameter can set many different values, such as "slow", "fast", "normal", or milliseconds.

tip: because JavaScript statements (directives) are executed one-by-in-order, the statements after the animation may produce errors or page conflicts because the animation is not yet complete.

To avoid this situation, you can add the Callback function as a parameter.

Instance

The following instances are callback functions after the hidden effect is fully implemented:

Use callback instance $ ("button"). Click (function () {
$ ("P"). Hide ("Slow", function () {
Alert ("The paragraph is now hidden");
});
});
Try

The following instance does not have a callback function, and the warning box pops up before the hidden effect is complete:

There is no callback (callback) $ ("button"). Click (function () {
$ ("P"). Hide (1000);
Alert ("The paragraph is now hidden");
});
Online example?

JQuery Callback method

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.