The hasChildNodes Method


The hasChildNodes Method

The 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

Method

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

hasChildNodes()

     

x

     

x

x

x

 

Returns: Boolean

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.)



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net