JavaScript Reference/Javascript Methods/hasChildNodes

Материал из Web эксперт
Перейти к: навигация, поиск

"hasChildNodes()" Example

   <source lang="javascript">
   

<html> <body> <script language="JavaScript"> function function1() {

   alert(document.getElementById("myText").hasChildNodes());

} </script>

This sample text has child nodes.

<button onclick="function1();">HasChildNodes</button> </body> </html>


     </source>
   
  


"hasChildNodes()" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<a> <acronym> | | |<address> <applet> | | |<area> attribute | | | <base> | | |<basefont> |

| |
|

| |<body>
| | |<button> |

| |
|

| | <col> | | |<colgroup> <comment> | | |

| | | <dir> |

| |
|

| |

| | |<embed> <fieldset> | | | <form> | | |<frame> <frameset> | | |<head> <hn> |

| |
<html> |

| | <iframe> | | |<img> <input type="button"> | | |<input type="checkbox"> <input type="file"> | | |<input type="image"> <input type="password"> | | |<input type="radio"> <input type="reset"> | | |<input type="submit"> <input type="text"> | | | <isindex> | | | <label> |

| |<legend>
  • | | |<link> <listing> | | |<map> <marquee> | | |<menu> <meta> | | |<noframes> <noscript> | | |<object>
      | | |<optgroup> <option> | | |

      <param> | | |<plaintext>

                               |
      |                |                                                        |
      |                |                          <script>                      |
      |                |<select>                                               |
      |                |                                                |
      |                |                        <style>                       |
      |                |                                                    |
      |                |                         <tbody>                       |
      |                |                          |
      |                |                             
        | | | <xmp> | +----------------+--------------------------------------------------------------+ </source>

        "hasChildNodes()" Syntax, Parameters and Note

        <source lang="javascript"> Note: Does element have child nodes. Returns true or false.

        Syntax:

        document.getElementById("elementID").hasChildNodes() document.all.elementID.hasChildNodes() // IE only


        </source>

      <textarea> | | |<tfoot> |

      | |<thead> <title> |

      | |