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