all 컬렉션이나 다른 컬렉션들로부터 지정된 개체를 반환한다.

Script[oObj=]collection.item(vIndex[,iSubIndex])
인수/파라메터
vIndex
필수적인 요소이며, 반환할 개체나 컬렉션을 지정하는 정수값이나 문자열이다.
이 파라메터가 정수값이면, 0으로부터 시작하는 개체의 인수(index)이다.
이 파라메터가 문자열이면, name이나 id 속성이 일치하는 모든 개체들과 한개 이상이면 컬렉션을 반환한다.
iSubIndex
선택적인 요소이며, 컬렉션으로 반환되는 경우 반환될 개체를 0으로부터 시작하는 개체의 인수(index)를 나타내는 정수값이다.
반환값

반환값 oObj은 성공적이면 개체들의 컬렉션을 반환하고, 실패하면 null을 반환한다.

특기

item 메서드는 form로 부터 input type=image 엘레멘트를 반환할 수 없다.
모든 엘레멘트에 접속하기 위하여 children 컬렉션을 사용하여야 한다.

적용
개체scriptIE
allall.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
anchorsanchors.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
appletsapplets.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
areasareas.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
boundElementsboundElements.item(vIndex[,iSubIndex])IE5(win16,win32,unix,mac)
cellscells.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
elementselements.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
embedsembeds.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
formsforms.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
imagesimages.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
linkslinks.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
mimeTypesmimeTypes.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
optionsoptions.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
pluginsplugins.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
rowsrows.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
scriptsscripts.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
tBodiestBodies.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
formform.item(vIndex[,iSubIndex])IE4.0(win16,win32,ce,unix,mac)
참조

이 메서드는 (영어)DOM Level 1(Document Object Model Level 1)에서 정의되었다.


method
item 메서드
item</b> 메서드
예제
이전페이지로페이지 맨위로페이지 맨아래로

간단한 italics 메서드 예제

결과 표시창

item 메서드를 사용하여 문서내의 모든 엘레멘트를 디스플레이한다.

<SCRIPT>
function showAll(){
  var coll=document.all;
  str='coll.length='+coll.length+'<BR>';
  if (coll!=null){
    for (i=0;i< coll.length;i++) str+=i+'] '+coll.item(i).tagName+', ';
  }
  showA.innerHTML=str;
}
</SCRIPT>
<BUTTON onclick=showAll()>모든 태그를 디스플레이한다.</BUTTON>
<DIV id=showA style=font-size:9pt>결과 표시창</DIV>

method
item 메서드
item</b> 메서드
견본
이전페이지로페이지 맨위로페이지 맨아래로
Test1 Span Test2 Span
결과 표시창

item 메서드를 사용하여 id가 일치하는 엘레멘트의 컬렉션을 찾아 디스플레이한다.

<SCRIPT>
function showTest(){
  var coll=document.all.item('Test');
  str='coll.length='+coll.length+'<BR>';
  if (coll !=null){
    for (i=0;i< coll.length;i++){
      str+=i+'] coll.item('+i+').tagName='+coll.item(i).tagName+', coll.item('+i+').innerText='+coll.item(i).innerText+'<BR>';
    }
  }
  showB.innerHTML=str;
}
</SCRIPT>
<SPAN id="Test" style="border:solid 1 blue">Test1 Span</SPAN>
<SPAN id="Test" style="border:solid 1 blue">Test2 Span</SPAN><BR>
<BUTTON onclick="showTest()">모든 Test를 디스플레이한다.</BUTTON>
<DIV id=showB style=font-size:9pt>결과 표시창</DIV>
결과 표시창

item 메서드를 사용하여 id가 일치하는 엘레멘트의 컬렉션을 찾아 iSubIndex 파라메터로 개별 항목을 디스플레이한다.

<SCRIPT>
function showOneTest(){
  var coll=document.all.item('Test')
  str='coll.length='+coll.length+'<BR>';
  if (coll!=null) {
    for (i=0;i< coll.length;i++){
      str+=i+'] coll.item("Test",'+i+').tagName='+coll.item('Test',i).tagName;
      str+=', coll.item("Test",'+i+').innerText='+coll.item('Test',i).innerText+'<BR>';
    }
  }
  showC.innerHTML=str;
}
</SCRIPT>
<BUTTON onclick="showOneTest()">모든 Test를 디스플레이한다.</BUTTON>
<DIV id=showC style=font-size:9pt>결과 표시창</DIV>
method
item 메서드
견본예제
이전페이지로페이지 맨위로
최종 수정:
05/18/2025 12:06:43
KoXo Homepage
All right reserved
비정상적인 방식으로 프레임없이 페이지에 접속하면 자주 오류가 발생됩니다.
오류가 나면 정상적 접속으로 시도해 보세요.
http://koxo.com/lang/js/method/item_all.html