We have been using a single statement at once, but now using the chaining method we can bind multiple methods to make the code short. This way, browsers do not have to find the same element(s) more than once.
While using method chaining in jQuery, it ensures that there is no need to use the same selector more than once. Over-using a selector can seriously slow down your code, as every time you call on a selector you are forcing the browser to go looking for it. By combining or “chaining” multiple methods, you can seriously cut down on the number of times you make your browser look for the same elements without having to set any variables.
Code #1: Using Slide up and slide down method functions for chaining-
Code #2: Using animate function in jQuery for chaining effect-
- jQuery | jQuery.fx.interval Property with example
- jQuery | jQuery.support Property
- jQuery | jquery Property
- jQuery | jQuery.fx.off Property
- jQuery | die() Method
- jQuery | :gt() Selector
- jQuery | :not() Selector
- jQuery | finish() with Example
- jQuery | innerWidth() with Example
- jQuery | contains() Method
- jQuery | :lt() Selector
- jQuery UI | Button
- jQuery | has() with Examples
- jQuery | get() Method
- jQuery | :first Selector
- jQuery | Syntax
- JQuery | map() Method
- jQuery | is() Method
- How to get the value of a textarea in jQuery ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : AnweshanTheProgrammer