JavaScript Reference/Javascript Collections/children

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

"children" Example

   <source lang="javascript">
   

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

   var m = document.all.myBody.children;
   for (i=0; i<m.length; i++) 
   alert(m.item(i).tagName); 

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

      type="button" 
      value="Direct descendants of this body element" 
      onclick="function1();">

</body> </html>


     </source>
   
  


"children" is applied to

   <source lang="javascript">

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

| |
<body> |

| |<button> |

| |
|

| | <col> | | |<colgroup> <custom> | | |

| | | <dir> |

| |
|

| |

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

| |
<html> |

| | <iframe> | | |<img> | | | <label> |

| |<legend>
  • | | |<link> <listing> | | |<map> <marquee> | | |<menu>
      | | |<option>

      | | |

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

        "children" JavaScript properties and JavaScript methods

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

        item(), length, tags(), urns()


        </source>



        "children" Syntax Parameters and Note

        <source lang="javascript"> Note: Returns an array of all first-generation elements of the element.

        Syntax:

        document.all.elementID.children // returns all child elements document.all.elementID.children(param1, param2) // returns an individual child element


        param1 Required; zero-based index or desired member"s id or name attribute.

        param2 Optional; the zero-based index for the result returned if param1 matches more than one element.

        </source>

      <textarea> |

      | |<tfoot> <thead> |

      | |<title>