parentElement Gets the parent object in the object hierarchy.
parentNode gets the parent object in the document hierarchy.
childNodes Gets a collection of HTML elements and TextNode objects that are direct descendants of the specified object.
children Gets a collection of DHTML objects that are direct descendants of the object.
-------------------------------------------------- ------
parentNode has the same function as parentElement, and childNodes has the same function as children. However, parentNode and childNodes comply with W3C standards and can be said to be relatively universal. The other two are only supported by IE, not standards, and are not supported by Firefox.
-------------------------------------------------- ------
Just use 2 parentNodes and 2 childNodes. The answers above are all correct!
-------------------------------------------------- ------
Are the standards just different?
-------------------------------------------------- ------
This is not "different standards",
The other two are not standards at all;
It can be understood as customized by ie
-------------------------------------------------- ------
In other words, parentElement and children are IE's own things and are not recognized by other places.
Then, their standard version is parentNode, childNodes.
The functions of these two are the same as parentElement and children, and they are standard and universal.
-------------------------------------------------- ------
The following is a simple explanation, please pay attention to the differences in individual words:
parentNode Property: Retrieves the parent object in the document hierarchy.
[Ctrl+A to select all Note: If you need to introduce external Js, you need to refresh before executing]
Did you see that this bbb here affects the result?