From aa1428fb1565b743dd31245ee269198a54dd2b8a Mon Sep 17 00:00:00 2001 From: bendtherules Date: Wed, 4 Nov 2020 19:30:46 +0530 Subject: [PATCH] element-properties - Add parentElement section --- docs/element-properties.mdx | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/docs/element-properties.mdx b/docs/element-properties.mdx index abce158..86e1613 100644 --- a/docs/element-properties.mdx +++ b/docs/element-properties.mdx @@ -10,7 +10,7 @@ import MDN from "../components/MDNBadge" ### 1. tagName -`Element.tagName : string` +`Element.tagName: string` `.tagName` is a read-only property on any element, which returns the tag name in uppercase form. This is useful to identify type of a element. @@ -32,7 +32,22 @@ Text nodes are not element, so they don't have any tagName. To identify the type   - + +### 2. parentElement + +`Node.parentElement: Element | null` + +`.parentElement` property returns **the parent element** of the current node. If the node doesn't have a parent, it returns null. + +Usually, the last parent will be `document` - which itself doesn't have a parent. + +```js +
+
+
+ +child.parentElement //
-### 3. childNodes +### 4. childNodes `Node.childNodes: NodeList` @@ -148,7 +163,7 @@ This is equivalent to checking `node.childNodes.length > 0`. -### 4. firstChild + nextSibling +### 5. firstChild + nextSibling `Element.firstChild: Node` @@ -219,8 +234,6 @@ traverse(root.firstChild)