Js parentNode parentElement .childnodes the difference between the children

  • 2020-03-30 00:00:17
  • OfStack

ParentElement gets the parent object in the object hierarchy.  
ParentNode gets the parent object in the document hierarchy.  
ChildNodes gets the 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.  

--------------------------------------------------------

--------------------------------------------------------

Use this parentNode,childNodes 2.

--------------------------------------------------------

Just different standards?

--------------------------------------------------------

This is not "standards are different",
The other two aren't standards at all,
Can be understood as ie custom

--------------------------------------------------------

That is to say, parentElement and children are owned by IE and not recognized elsewhere.
So, their standard version is parentNode,childNodes.
These two functions are the same as parentElement and children, and they are standard and universal.

--------------------------------------------------------

Here is a brief explanation, note the difference in individual words:
ParentNode Property: Retrieves the parent object in the document hierarchy.

ParentElement Property:Retrieves the parent object in the object hierarchy.

.childnodes:
Retrieves a collection of HTML Elements and TextNode objects that are direct descendants of the specified object.

Children:
Retrieves a collection of DHTML Objects that are direct descendants of the object.

--------------------------------------------------------

I also took two paragraphs from the DHTML manual
ParentElement children:
There is no public standard that applies to this property/collection.
ParentNode.childnodes:
This property/collection is defined in the World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1.


Related articles: