NodeList
의 node를 index로 돌려줍니다. 이 메서드는 인수(arguments)를 제공하는 한 exceptions 을 throw 하지 않습니다. index가 범위를 벗어나면 null
값이 반환되고, 인수가 제공되지 않으면 TypeError
가 throw 됩니다.
Syntax
nodeItem = nodeList.item(index)
nodeList
는NodeList
입니다. 일반적으로 childNodes 와 같은 다른 DOM 속성(property) 또는 메서드에서 가져옵니다.index
는 fetch될 node의 index입니다. index는 0 에서 부터 시작합니다.nodeItem
은item
메서드가 반환 한nodeList
의 nodeindex
입니다.
Alternate Syntax
자바스크립트는 NodeList 에서 index를 얻기 위한, 배열과 같은 브라켓 문법([])을 제공합니다 :
nodeItem = nodeList[index]
Example
var tables = document.getElementsByTagName("table");
var firstTable = tables.item(1); // or simply tables[1] - returns the second table in the DOM
Specification
Browser compatibility
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.