HTMLAllCollection: namedItem() method

The namedItem() method of the HTMLAllCollection interface returns the first Element in the collection whose id or name attribute matches the specified name, or null if no element matches.

Syntax

js
namedItem(name)

Parameters

name

A string representing the value of the id or name attribute of the element we are looking for.

Return value

The first Element in the HTMLAllCollection matching the name, or null, if there are none.

Specifications

Specification
HTML
# dom-htmlallcollection-nameditem

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
namedItem

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support