What is getElementsByTagName in JavaScript?

Why is getElementsByTagName used?

getElementsByTagName is used to get a list of elements with a specified TagName. The returned list will basically be a live HtmlCollection ff elements in the same order as in the source file.

The Indexing of Returned listwhere list elements are called as Nodes of HtmlCollection starts at 0.

Syntax

document.getElementsByTagName(TagName)
Examples

Free Resources