NodeList.item()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

NodeList 의 node를 index로 돌려줍니다. 이 메서드는 인수(arguments)를 제공하는 한 exceptions 을 throw 하지 않습니다. index가 범위를 벗어나면 null 값이 반환되고, 인수가 제공되지 않으면 TypeError 가 throw 됩니다.

Syntax

js
nodeItem = nodeList.item(index);
  • nodeListNodeList 입니다. 일반적으로 childNodes 와 같은 다른 DOM 속성(property) 또는 메서드에서 가져옵니다.
  • index 는 fetch될 node의 index입니다. index는 0 에서 부터 시작합니다.
  • nodeItemitem 메서드가 반환 한 nodeList 의 node index 입니다.

Alternate Syntax

JavaScript는 NodeList 에서 index를 얻기 위한, 배열과 같은 브라켓 문법([])을 제공합니다 :

js
nodeItem = nodeList[index];

Example

js
var tables = document.getElementsByTagName("table");
var firstTable = tables.item(1); // or simply tables[1] - returns the second table in the DOM

Specification

브라우저 호환성

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
item

Legend

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

Full support
Full support