This article is the official HTML5 training course for h5edu institutions, mainly introduces: JavaScript intensive tutorial--jquery-chaining
With JQuery, you can link actions/methods together.
Chaining allows us to allow multiple jQuery methods (on the same element) in one statement.
JQuery Method Links
Until now, we have written a jQuery statement one at a time (followed by another).
However, there is a technique called link (chaining) that allows us to run multiple jQuery commands on the same element, one after the other.
Tip: In this case, the browser does not have to look for the same elements multiple times.
To link an action, you simply append the action to the previous action.
Example 1
The following example links CSS (), Slideup (), and Slidedown () together. The "P1" element first turns red, then slides up, then moves downward: $ ("#p1"). CSS ("Color", "red"). Slideup (2000). Slidedown
We can also add multiple method calls, if needed.
Tip: When you make a link, the code line becomes very poor. However, JQuery is not syntactically rigorous; you can write in the format you want, including lines and indents.
Example 2
This can also run: $ ("#p1"). CSS ("Color", "red"). Slideup (+). Slidedown (2000);
JQuery will throw away the extra spaces and execute the lines of code as a line of code.
Click to enter JS Intensive tutorial: http://www.h5edu.cn/htm/step/h5edu_44.html
JavaScript Intensive Tutorial--jquery-chaining