Examples of differences between jquery neutron elements and descendant Elements

Source: Internet
Author: User

Learn jQuery selector today:

JQuery selectors include basic selectors, hierarchical selectors, filter selectors, and form selectors.

Basic selector: id, class, label name, *, element combination (div, span, p. myClass)

Level selector:

Difficulty: differences between jquery neutron elements and descendant Elements
The descendant, that is, all descendants of the current element, are counted,
Child element, which is a subset of the current element, is not counted if you go down.

For detailed analysis, refer:
Copy codeThe Code is as follows:
<Div> This is <strong> very </strong> important. </div>
<Div> This is <em> really <strong> very </strong> </em> important. </div>

The above is html. After running it, you can see it in the browser.

This is very important.
This is really very important.

To make it easy to see the effect, try adding css colors.

If you run $ ("div strong" ).css ("color", "red"), the child element strong of the div is changed to red. After running is

This is very important.
This is really very important.

If you run $ ("div> strong" ).css ("color", "blue"), the child element strong of the div is changed to blue. After running is

This is very important.
This is really very important.

It can be understood in a plain way. For example, if a family has three generations in the same hall, grandpa, father, and you, the child element of Grandpa is your father. At the same time, your father is also a descendant element of Grandpa, you are just a descendant of Grandpa.

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.