The hasChildNodes MethodThe hasChildNodes method returns true if a W3C node has child nodes, false otherwise . You can see the support for this method in Table 6.28. Table 6.28. The hasChildNodes Method
The hasChildNodes method is useful to check whether a node has any child nodes before you try to use a property such as childNodes , which holds all the child nodes. (If your code relies on childNodes not being empty, for instance, it can crash unless you check to make sure there are actually child nodes before using the childNodes collection.) |