all 컬렉션이나 다른 컬렉션들로부터 지정된 개체를 반환한다.
![]() | Script | [oObj=]collection.item(vIndex[,iSubIndex]) |
반환값 oObj은 성공적이면 개체들의 컬렉션을 반환하고, 실패하면 null을 반환한다.
item 메서드는 form로 부터 input type=image 엘레멘트를 반환할 수 없다.
모든 엘레멘트에 접속하기 위하여 children 컬렉션을 사용하여야 한다.
개체 | script | IE |
---|---|---|
all | all.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
anchors | anchors.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
applets | applets.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
areas | areas.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
boundElements | boundElements.item(vIndex[,iSubIndex]) | IE5(win16,win32,unix,mac) |
cells | cells.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
elements | elements.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
embeds | embeds.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
forms | forms.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
images | images.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
links | links.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
mimeTypes | mimeTypes.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
options | options.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
plugins | plugins.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
rows | rows.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
scripts | scripts.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
tBodies | tBodies.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
form | form.item(vIndex[,iSubIndex]) | IE4.0(win16,win32,ce,unix,mac) |
이 메서드는 (영어)DOM Level 1(Document Object Model Level 1)에서 정의되었다.
![]() | item 메서드⇒ | ![]() | ⇒ | ![]() ![]() ![]() |
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>
![]() | item 메서드⇒ | ![]() | ⇒ | ![]() ![]() ![]() |
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>
![]() | item 메서드 | ⇒ | ![]() ![]() |
최종 수정: 05/18/2025 12:06:43 | ![]() All right reserved | 비정상적인 방식으로 프레임없이 페이지에 접속하면 자주 오류가 발생됩니다. 오류가 나면 정상적 접속으로 시도해 보세요. | http://koxo.com/lang/js/method/item_all.html |