JavaScript Intensive Tutorial--jquery-chaining

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.