#43 Callback and Chaining in JQuery Effects 2019

Опубликовано: 18 Март 2026
на канале: JavaScript
27
0

#43 Callback and Chaining in JQuery Effects 2019
Callback -
A callback function is executed after the current effect is 100% finished. JavaScript statements are executed line by line. However, with effects, the next line of code can be run even though the effect is not finished. This can create errors.
To prevent this, you can create a callback function.
A callback function is executed after the current effect is finished.
Typical syntax: $(selector).hide(speed,callback);

Chaining -
With jQuery, you can chain together actions/methods.
Chaining allows us to run multiple jQuery methods (on the same element) within a single statement.
Until now we have been writing jQuery statements one at a time (one after the other).
However, there is a technique called chaining, that allows us to run multiple jQuery commands, one after the other, on the same element(s).
Tip: This way, browsers do not have to find the same element(s) more than once.
To chain an action, you simply append the action to the previous action.
Example -
$("#p1").css("color", "red").slideUp(2000).slideDown(2000);

Some more inbuilt effects - https://www.w3schools.com/jquery/jque...

Video by - Tanmay Sakpal
Simple Snippets Channel link -    / simplesnippets  
Social Network for Developers ☞ https://morioh.com
Developer's Store ☞ https://www.moteefe.com/store/develop...
Learn to code for free and get a developer job ☞ https://codequs.com/

Original video source:
----------------------------------------------------
Social Network for Developers: https://morioh.com
Learn Startup: https://learnstartup.net
Learn to code: https://codequs.com
Fanpage:   / codek.tv  
Twitter:   / i_am_adeveloper  
Tumblr:   / codequsdotcom