document.all.item()

JScript 3.0+ IE 4+ Syntax

document.all.item(name)

Description

The item() method provides a way to retrieve an HTML element out of the document.all array without having to know its position in the array. Instead of using an index position, the item() method allows you to just pass in the name of the element as specified by the name or id attribute of HTML tags. Normally, the method returns the element, but, if more than one element is found with the same name, an array of elements is returned.

Example

Listing 7.51 uses the item() method to access the Paint anchor. Using dot notation, the name of the anchor is used to create a link to the top of the page.

Listing 7.51 Using the item() Method to Find a Particular HTML ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.