HTMLAllCollection: namedItem() method

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("DOM")}}

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

Syntax

js-nolint
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 {{domxref("Element")}} in the {{domxref("HTMLAllCollection")}} matching the name, or [null](/en-US/docs/Web/JavaScript/Reference/Operators/null), if there are none.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}