all collection
Represents a collection of all elements contained by an element or the entire document.
The elements in the collection are sorted in source code order.
The all collection is not supported by Firefox.
For a cross-browser solution, to get elements by name or id, use the getElementsByName and getElementById methods, to get all child elements of an element, use the childNodes collection.
Syntax:
Properties that reference the object:
| object.all |
Related objects:
Related HTML objects:
a, abbr, acronym, address, applet, b, bdo, big, blink, blockquote, body, button, caption, center, cite, code, col, colgroup, dd, del, dfn, dir, div, dl, dt, em, fieldset, font, form, frameset, h1, h2, h3, h4, h5, h6, head, html, i, img, ins, kbd, keygen, label, legend, li, listing, map, marquee, menu, nobr, noframes, noscript, object, ol, optgroup, option, p, plaintext, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tbody, td, textarea, tfoot, th, thead, tr, tt, u, ul, var, xmp
|
The base interface, through which you can add new functionalities to the all collection, is the HTMLCollection interface.
Possible members:
Properties:
Returns an integer that specifies the number of elements in the current collection.
This property is read-only. |
Methods:
[nameOrIndex] |
Returns an element or a collection of elements from the current collection by name or index.
Parameters:
Return value:
|
||||||||||||||||||||||
item (nameOrIndex [, subIndex]) |
Returns an element or a collection of elements from the current collection by name or index.
Parameters:
Return value:
|
||||||||||||||||||||||
namedItem (name) |
Returns an element or a collection of elements from the current collection by name.
Parameters:
Return value:
|
||||||||||||||||||||||
tags | Returns a NodeList collection that contains all elements from the current collection with the specified tag name. | ||||||||||||||||||||||
urns | Returns a NodeList collection that contains all elements to which the specified behavior is attached. |
Example HTML code 1:
This example illustrates the use of the all collection:
|
||||
<head> <script type="text/javascript"> function GetTableInnerHTML () { if (document.all) { // Internet Explorer, Opera, Google Chrome and Safari var table = document.all.namedItem ("myTable"); } else { var table = document.getElementById ("myTable"); } alert (table.innerHTML); } </script> </head> <body> <button onclick="GetTableInnerHTML ();">Get the innerHTML of the table!</button> <br /><br /> <table id="myTable" border="1px"> <tbody> <tr> <td>First row in the table.</td> </tr> </tbody> </table> </body> |
||||
|
||||
Did you find this example helpful?
|
External links:
User Contributed Comments