Net-informations.com
SiteMap  | About    

jQuery Callback Function



jQuery is based on JavaScript. JavaScript statements are run one line after another, however, effects may be run despite another effect may not be finished yet, causing errors and unexpected behaviors. Similarly, the code in jQuery will also execute sequentially. When we use animation in jQuery the execution order of code will be changed. In other words it will execute the next line of the code without waiting to complete the first line. Callback functions prevent this from happening as they form a queue, preventing another effect from being executed before the current one is complete. Then lend structure and timing to our code.

In the above code, you can see the callback function itself is defined in the third argument passed to the function call. That code has another alert message to tell you that the callback code has now executed.

run this source code Try it Yourself
jQuery Callback()

Full Source

The example below has no callback parameter , and the alert box will be displayed before the animation effect is completed:

run this source code Try it Yourself
jQuery Callback()

Full Source









net-informations.com (C) 2018    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.