jquery Chain-action
In jquery, after executing the method, the current object (return this )is returned, and the object can of course continue to invoke the method, so we can do the chaining.
Let's start with an example:
$ ("Li"). CSS ("Color", "gold"). Prevall (). CSS ("Color", "gold");
Call CSS () to a JQuery object to modify the node style, and then use Prevall (). CSS () to modify the style of all sibling nodes before the node, which is called a chain-like operation.
Chained operations can make the code concise, because it is often possible to implement more than one statement in a single statement to accomplish a task.
If you do not use chained operations, you need to use two statements to complete the above tasks:
$ ("Li"). CSS ("Color", "gold");
$ ("Li"). Prevall (). CSS ("Color", "gold");
In addition to increasing the amount of code, also called two times the selector, reducing the speed.