JavaScript Intensive tutorial--jquery Callback functions

Source: Internet
Author: User

This article ish5eduAgency officialHTML5 Training HTML5 Trainingtutorials, the main introduction:JavaScript Intensive Tutorials--jquery Callback function
 
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. Example

[Size=14]$ ("button"). Click (function () {$ ("P"). Hide (1000);}); [/size]


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.
jQuery Callback function
when animation 100% is complete, the Callback function is called. A typical syntax:

[Size=14]$ (selector). Hide (Speed,callback) [/size]


The callback parameter is a function that is executed after the hide operation is completed. Error (no callback)

[Size=14]$ ("P"). Hide (+); alert ("The paragraph is now hidden"); [/size]

Correct (with callback)

[Size=14]$ ("P"). Hide (1000,function () {alert ("the paragraph is now hidden");}); [/size]

Click to enter JS Intensive tutorial

This article is from the "11721999" blog, please be sure to keep this source http://11731999.blog.51cto.com/11721999/1839796

JavaScript Hardening Tutorial--jquery Callback functions

Related Article

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.