웹 프로그래밍

웹 프로그래밍 52

특정 태그에 사용하는 요소들을 얻어내기getElementsByTagName("인수") 메소드

getElementsByTagName("인수") element.getElementsByTagName(tag) document.geElemetsByTagName("li") : 문서내에 특정 태그를 사용하는 요소들의 배열로서 얻어낼 수 있는 함수 : 한개가 아닌 여러개의 요소를 얻게 된다. # 참조한 요소의 갯수를 반환하기 alert(documet.geElementsByTagName("li").length); # 문소내의 모든 요소 노드의 개수를 반환하기 alert(documet.geElementsByTagName("*").length); ex) 땅콩 치즈 우유 결과 : 얼럿 li의 개수 반환 3