getElementsByTagName Method Sample
This sample uses the getElementsByTagName method to return a collection of child elements with the specified tag name.
Click one of the list items below.
The getElementsByTagName method is invoked on the parent element of the clicked item.
The first and last elements in the returned collection and the length of the collection are displayed in the table.
Using the DHTML Object Model: var aDivs = document.body.all.tags("div");
Using the DOM:var aDivs = document.body.getElementsByTagName("div");
Data |
First child | |
Last child | |
Length Item | |
- Item 1*
- Sub Item 1.1*
- Super Sub Item 1.1
- Super Sub Item 1.2
- Super Sub Item 1.3*
- Super Sub Item 1.3.1
- Super Sub Item 1.3.2
- Sub Item 1.2
- Sub Item 1.3
- Item 2*
- Sub Item 2.1
- Sub Item 2.3
- Item 3
[Frames Site Entry Point]
[MVC Entry Point]
[Site Entry Point]
[SignalR:MoveSquare]
▶SignalR: Form Using KnockOut
ModelViewController: Standard Razor