The difference between the neutron element and the descendant element of jquery

Source: Internet
Author: User

This article reprinted, the original website address: http://blog.sina.com.cn/s/blog_775da6710100vzbr.html

For friends who have just learned jquery, there are times when there is a point of understanding about jquery's Layer selector $ ("ancestor descendant") and $ ("Parent>child"). In fact, it is very simple, after reading the following example you will completely understand.

<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 in the browser is to see

This is veryImportant. This is really very Important.

This style, in order to easily see the effect, we might as well try to add CSS color to try

If you run $ ("div strong"). CSS ("Color", "red"), the strong of the descendant elements of the div is changed to red. After the run is

This is veryImportant. This is really very Important. If you run $ ("Div>strong"). CSS ("Color", "blue"), the child element of the div is strong to blue. After the run is the IS veryImportant. This is really very Important.

See here I think should all understand, if not understand, can be popular so understanding, such as a family three generations together, Grandpa, Father and you, so grandpa's son element is your father, and your father is also the descendants of Grandpa elements, and you are only the descendants of Grandpa elements.

The difference between the neutron element and the descendant element of jquery

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.