The descendant is all descendants of the current element. The child element is the subset of the current element. If you go down, you will not forget to learn jQuery's selector today:
JQuery selectors include basic selectors, hierarchical selectors, filter selectors, and form selectors.
Basic selector: id, class, label name, *, element combination (p, 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:
The Code is as follows:
This isVeryImportant.
This isReallyVeryImportant.
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 $ ("p strong" ).css ("color", "red"), the child element strong of p is changed to red. After running is
This is very important.
This is really very important.
If you run $ ("p> strong" ).css ("color", "blue"), the child element strong of p 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.