- How do I access a collection in HTML?
- How do I select an element by tag name?
- Which document method takes a tag name as a string and returns an HTML collection with the specified tag name?
- How to check tag name in JavaScript?
How do I access a collection in HTML?
An HTMLCollection is a collection of document elements. A NodeList is a collection of document nodes (element nodes, attribute nodes, and text nodes). HTMLCollection items can be accessed by their name, id, or index number. NodeList items can only be accessed by their index number.
How do I select an element by tag name?
Get Element(s) By Tag Name Using getElementsByTagName()
Call the getElementsByTagName() on the global document object. The getElementsByTagName() method takes one argument which is the tag name. It gets all div elements from the entire document and returns an array-like object called HTMLCollection.
Which document method takes a tag name as a string and returns an HTML collection with the specified tag name?
getElementsByTagName() The getElementsByTagName method of Document interface returns an HTMLCollection of elements with the given tag name.
How to check tag name in JavaScript?
To get the tag name of a specific HTML Element as a string, using JavaScript, get reference to this HTML element, and read the tagName property of this HTML Element. tagName is a read only property that returns the tag name of this HTML Element as a string.