Okay..As far as jQuery is concerned then undoubtedly Chaining is one of the most powerful feature of jQuery. Even in jQuery, Chaining means to connect multiple functions, events on selectors. To understand it better take a look at Sample Code 1 and 2.
Sample Code 1
Sample Code 2
The problem with the Sample Code 1 is that for every statement, jQuery has to search the entire DOM and find the element and after that executes the attached function on it. But when chaining is used, then jQuery has to find the element only once and it will execute all the attached functions one by one. This is the advantage of Chaining.
Important points about Chaining
- It makes your code short and easy to manage.
- It gives better performance.
- The chain starts from left to right. So left most will be called first and so on.