HTML DOM hasChildNodes() Method Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The HTML hasChildNodes() property will return true if the given node has a child node or false if it doesn't have any child nodes. A blank line or whitespace is also treated as a child node so it also returns true on a blank line or whitespace. Prerequisite DOM (Document Object Model) Parameters: No parameters are required. Return value: The HTML nodeValue property returns the following type of values. True if the given node has a child or blank space or a blank line.False if the given node doesn't have any child. Syntax node.hasChildNodes() Example 1: In the following paragraph tag has nothing so it returns false. HTML <!DOCTYPE html> <html> <body> <!--In this example we will create a node of the type div and a button which calls a function name "exampleFunction" on clicking of this button it will show the properties of hasChildNode property --> <p id="divId"></p> <br> <button onclick="exampleFunction()"> click to know the paragraph tag has any child node </button> <!-- below paragraph Tag is used to print the value of nodeValue properties--> <p id="GeeksForGeeks"></p> <script> // utility function to demonstrate hasChildNode Property function exampleFunction() { // let x used to get the information of those node // for which you want to perform // hasChildNode properties let res = document.getElementById("divId").hasChildNodes(); document.getElementById("GeeksForGeeks" ).innerHTML = res; } </script> </body> </html> Output: Example 2: In the following paragraph tag has a message so it returns true HTML <!DOCTYPE html> <html> <body> <!--In this example we will create a node of the type div and a button which calls a function name "exampleFunction" on clicking of this button it will show the properties of hasChildNode property --> <p id="divId">Hello geeksforgeeks</p> <br> <button onclick="exampleFunction()"> click to know the paragraph tag has any child </button> <!-- below paragraph Tag is used to print the value of nodeValue properties--> <p id="GeeksForGeeks"></p> <script> // utility function to demonstrate hasChildNode Property function exampleFunction() { // var x used to get the information of those nodes // for which you want to perform // hasChildNode properties. let res = document.getElementById("divId").hasChildNodes(); document.getElementById("GeeksForGeeks" ).innerHTML = res; } </script> </body> </html> Output: Supported Browsers: The browser supported by the DOM click() Method are listed below: Google Chrome 1 and aboveApple Safari 1 and aboveFirefox 1 and aboveOpera 12.1 and aboveEdge 12 and aboveInternet Explorer 6 and above Comment More infoAdvertise with us Next Article HTML DOM Datalist Object S Shahnawaz_Ali Follow Improve Article Tags : Web Technologies HTML HTML-DOM HTML-Methods Similar Reads HTML DOM Datalist Object The DOM Datalist Object is used to represent the HTML <Datalist> element. The Datalist element is accessed by getElementById(). Properties: It has an 'Option' attribute which is used to return the collection of all options values in a datalist. Syntax: document.getElementById("gfg"); Where "gf 2 min read HTML DOM nodeType Property The DOM nodeType Property is used to find out the type of the node that we are referring to. The type for a particular node is returned in numerical form. DOM nodeType property is a read-only property. Return value : It returns a numeric value as according to the type of node. 1: If node is an eleme 2 min read HTML DOM Cite Object The DOM Cite Object is used to represent HTML <Cite> element. The Cite element is accessed by getElementById(). Syntax: document.getElementById("id"); Where "id" is the ID assigned to the cite tag. Example 1: In this example, we will use DOM Cite Object HTML <!DOCTYPE html> <html> 1 min read HTML DOM Code Object The DOM Code Object is used to represent the HTML <code> element. The Code element is accessed by getElementById(). Syntax: document.getElementById("id"); Where 'id' is the ID assigned to the code tag. Example 1: In this example, we will use DOM Code Object HTML <!DOCTYPE html> <html 1 min read HTML DOM fullscreenEnabled() Method The fullscreenEnabled() method in HTML DOM is used to check whether the document can be viewed in full-screen mode or not. It returns a single read-only Boolean value. This method may require specific prefixes to work with different browsers. Syntax:document.fullscreenEnabled()Parameters: This metho 2 min read HTML DOM Caption Object The DOM Caption Object is used to represent the HTML <Caption> element (A caption element is used to specify the caption of a table). The Caption element is accessed by getElementById(). Properties: It has a align Attribute which is used to set or return the alignment of the caption. Syntax: d 2 min read HTML DOM Canvas Object The DOM Canvas Object is used to represent the HTML <Canvas> element. The <canvas> tag is used to draw graphics in the document using javascript. It is new in HTML5. The canvas element is accessed by getElementById(). Syntax: accessed by getElementById("id"). Where âidâ is the ID assigne 2 min read HTML DOM importNode() Method The HTML | DOM importNode() Method creates a copy of a node from another document and imports it to the current document. Syntax: document.importNode(externalNode, [deep]) Parameters: externalNode: Node which we need to import from another document, it can be of any type.[deep]: We can set its val 2 min read HTML DOM inputEncoding Property The inputEncoding property returns the character encoding used for parsing the document. This property doesn't have any default value. Syntax:document.inputEncodingParameters:The HTML DOM inputEncoding property does not require any parameter.Return Value:The HTML DOM inputEncoding property returns a 2 min read HTML DOM normalizeDocument() Method The normalizeDocument() method in HTML is used to normalize an HTML document by remove any empty text nodes if exists. After removing the empty nodes, it also merges all of the adjacent nodes present in the document. For Example, consider the below element: Element Geeks Text node: "" Text node: "He 2 min read Like