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.fx.off Property
- jQuery | jQuery.support Property
- jQuery | jquery Property
- JQuery | Multiple ID selectors
- jQuery | :input Selector
- jQuery | prepend() with Examples
- jQuery | dblclick() with Examples
- jQuery | offset() with Examples
- How to find the parent class name with known class in jQuery ?
- jQuery | Introduction
- jQuery | :nth-of-type() Selector
- How to Design Color Picker using jQuery UI ?
- jQuery | children() with Examples
- jQuery UI | position() Method
- jQuery | Hide/Show, Toggle and Fading methods with Examples
- JQuery | parseHTML() method
- jQuery | focusin() with Examples
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