HTML DOM parentElement Property Last Updated : 15 Jun, 2023 Comments Improve Suggest changes Like Article Like Report The DOM parentElement property is used to return the parent element of a particular child element. It is a read-only property. The parentElement and parentNode properties are similar and the only difference is the parentElement property returns null if the parent node is not an element. Syntax: node.parentElement Return Value: It returns a string that represents the parent node of any child node or it returns a null if the specified node does not contain any parent node. Example 1: In this example, we will use parentElement property. HTML <!DOCTYPE html> <html> <head> <title> HTML DOM parentElement Property </title> </head> <body> <h1 style="color:green;"> GeeksForGeeks </h1> <h2>DOM parentElement Property</h2> <ol type="1"> <li id="GFG">Quick Sort</li> <li>Merge Sort</li> <li>Selection Sort</li> <li>Heap Sort</li> </ol> <button onclick="Geeks()"> Submit </button> <p id="sudo"></p> <!-- script to find parentElement --> <script> function Geeks() { let w = document.getElementById("GFG").parentElement.nodeName; document.getElementById("sudo").innerHTML = w; } </script> </body> </html> Output: Example 2: This example hides the parent element to click on the close icon. HTML <!DOCTYPE html> <html> <head> <title> HTML DOM parentElement Property </title> <!-- CSS property to create box--> <style> div { padding: 16px; width: 70%; background-color: green; color: white; border-radius: 30px; } .GFG { float: right; font-size: 30px; font-weight: bold; cursor: pointer; } </style> </head> <body> <center> <h2>DOM parentElement Property</h2> <div> <span class="GFG" onclick="this.parentElement.style.display = 'none';"> × </span> <p style="font-size:30px;">GeeksforGeeks.</p> </div> </center> </body> </html> Output: Supported Browsers: The browser supported by DOM parentElement property are listed below: Google Chrome 1.0 and aboveEdge 12 and aboveInternet Explorer 8 and aboveFirefox 9.0 and aboveOpera 7 and aboveSafari 1.1 and above Comment More infoAdvertise with us Next Article HTML DOM parentElement Property M manaschhabra2 Follow Improve Article Tags : Web Technologies HTML Web technologies HTML-DOM Similar Reads HTML DOM cloneNode() Method The HTML DOM cloneNode() Method is used to copy or clone a node on which the cloneNode() method is called. For example, a list item can be copied from one list to another using this method.Syntax: yourNode.cloneNode([deep]) Parameters: The [deep] is an optional argument. We can set its value to "tru 3 min read HTML onunload Event Attribute The onunload event attribute works when the document is being unloaded i.e. it occurs when the browser has been closed. It is mostly used when the user opens a link and submits the form and closes the browser window. Basically, it is: Fired when a user navigates away from a page or closes the browse 1 min read HTML DOM exitFullscreen() Method The exitFullscreen() method requests the element which is currently in full-screen mode to be taken out of full-screen mode. If the element is not in full-screen mode, then nothing gets changed. The reverse of this method is requestFullscreen(). Syntax: HTMLElementObject.exitFullscreen() Parameters: 1 min read HTML DOM children Property The DOM children property is used to return an HTML collection of all the child elements of the specified element. The elements in the collection can be accessed by index numbers. It differs from childNodes as childNodes contain all nodes (i.e. it includes text and comment nodes as well) but on the 2 min read HTML DOM button Object The button object in HTML is used to represent a <button> element. The getElementById() method is used to get the button object. Property Values:Property ValuesDescriptionautofocusSets or returns whether a button should automatically get focused on page load.defaultValueSets or returns the def 3 min read HTML DOM scrollLeft Property HTML DOM scrollLeft property is used to return or set the number of pixels an element i.e. scrolled horizontally. If the content of the element doesn't generate a scroll bar, then its scrollLeft value is 0; Syntax: It returns the scrollLeft property.element.scrollLeftIt is used to set the scrollLef 3 min read HTML DOM scrollHeight Property The DOM scrollHeight property is used to return the height of an element. This property includes padding and also content that is not visible on the screen due to overflow but does not include a border, scrollbar, or margin. It is a read-only property. Syntax: element.scrollHeight Return Value: It r 1 min read HTML DOM lastElementChild Property The DOM lastElementChild property is used to return the last child element of the specified element or null if there is no last element. It is similar to the lastChild property but the difference is that the lastChild property returns all last-child nodes i.e. it includes text and comment nodes as w 1 min read HTML DOM hasAttributes() Method The HTML DOM hasAttribute() method is a boolean function that returns either true or false but not both. This method returns a true value if the element contains an attribute otherwise, it returns false. It is very useful to know whether the element in the document has attributes or not. Syntax: nod 2 min read HTML DOM contains() Method The contains() method is used to find whether the specified node is a descendant of the given node. This descendant can be a child, grandchild, great-grandchild, and so on. Syntax: node.contains( otherNode ) Parameters: The âothernodeâ in the syntax is the parameter required in this function. Return 1 min read Like