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