HTML DOM getElementsByTagName()Method
Examples
Returns a collection of objects with the specified tag name:
document.getElementsByTagName("P");
Try it Yourself »
Definition and Usage
The getElementsByTagName() method returns a collection of objects with the specified tag name.
Tip:The parameter value "*" returns all elements in the document.
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the getElementsByTagName() method
Syntax
document.getElementsByTagName(tagname)
Parameters
| Parameters | Type | Description |
|---|---|---|
| tagname | String | Required. The tag name of the element you want to get. |
Return Value
| Type | Description |
|---|---|
| NodeList object | A collection of elements with the specified tag name |
Technical Details
| DOM Version | Core Level 1 Document Object |
|---|
Other Extensions
Document Object