NodeList
Stay organized with collections
Save and categorize content based on your preferences.
The NodeList
interface provides the abstraction of an ordered
collection of nodes, without defining or constraining how this collection
is implemented. NodeList
objects in the DOM are live.
The items in the NodeList
are accessible via an integral
index, starting from 0.
See also the Document Object Model (DOM) Level 3 Core Specification.
Public Method Summary
abstract
int
|
|
abstract
Node
|
item(int index)
Returns the index th item in the collection.
|
Public Methods
public
abstract
int
getLength
()
The number of nodes in the list. The range of valid child node indices
is 0 to length-1
inclusive.
public
abstract
Node
item
(int index)
Returns the index
th item in the collection. If
index
is greater than or equal to the number of nodes in
the list, this returns null
.
Parameters
index |
Index into the collection. |
Returns
- The node at the
index
th position in the
NodeList
, or null
if that is not a valid
index.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["`NodeList` provides an ordered collection of nodes, accessible via index."],["`NodeList` objects are live, meaning they automatically update to reflect changes in the document."],["`getLength()` method returns the total number of nodes in the list."],["`item(int index)` method allows access to individual nodes within the list by index."]]],["`NodeList` provides an ordered collection of nodes, accessible via an integer index starting from 0. The `getLength()` method returns the total number of nodes in the list. The `item(int index)` method retrieves a specific node at the given index; it returns `null` if the index is out of bounds. `NodeList` objects are live within the DOM. Valid child node indices range from 0 to `length-1`.\n"]]