HTML DOM Collections
DOM Collections are live collections of DOM elements. They are similar to arrays but provide additional methods and properties specifically designed for manipulating groups of elements.
Understanding how to work with DOM Collections is crucial for effectively manipulating multiple elements at once.
How to Access DOM Collections
There are several methods that return DOM Collections:
- getElementsByClassName(): Returns a collection of elements with a specific class name.
- getElementsByTagName(): Returns a collection of elements with a specific tag name.
- querySelectorAll(): Returns a static NodeList of elements that match the specified CSS selector.
What are DOM Collection Properties and Methods
Property that returns the number of elements in the collection.
Method that returns the element at the specified index.
Method that returns the named element from an HTMLCollection.