JavaScript Reference/Javascript Collections/childNodes

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

"childNodes" Example

   <source lang="javascript">
   

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

   var m = document.all.myBody.childNodes;
   alert(m.length) 

} </script> </head> <body id="myBody"> <input id=myB

      type="button" 
      value="How many child nodes have this body element?" 
      onclick="function1()">

</body> </html>


     </source>
   
  


"childNodes" is applied to

   <source lang="javascript">

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

| |
|

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

| |
|

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

| | | <dir> |

| |
|

| |document

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

| |<hn>
|

| |<html> | | |<iframe> <img> | | | <isindex> | | | <label> |

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

      <param> | | |

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

        "childNodes" JavaScript properties and JavaScript methods

        <source lang="javascript"> JavaScript properties and JavaScript methods

        item(), length, urns()


        </source>



        "childNodes" Syntax Parameters and Note

        <source lang="javascript"> Note: Returns an array of all first-generation nodes, including text nodes, of the object.

        Syntax:

        document.getElementById("elementID").childNodes // returns all child nodes document.getElementById("elementID").childNodes(param1) // returns an individual child node document.all.elementID.childNodes // IE only document.all.elementID.childNodes(param1) // IE only

        param1 Required; zero-based index


        </source>

      |

      | |<textarea> <tfoot> |

      | |
      <thead> | | |<title>