Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM getElementsByTagName() method

HTML DOM getElementsByTagName() method

Document Object Reference Document Object

Example

Return a collection of objects with the specified tag name:

document.getElementsByTagName("P");

Try it »

Definition and Usage

The getElementsByTagName() method returns a collection of objects with the specified tag name.

Tip: The parameter value "*" returns all elements of the document.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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

Document Object Reference Document Object