HTML DOM 문서 앵커
예
문서의 <a> 요소 수:
let num = document.anchors.length;
첫 번째 <a> 요소의 내용:
let content = document.anchors[0].innerHTML;
정의 및 사용
anchors 속성은 더 이상 사용되지 않습니다. 사용하지 마십시오.
anchors 속성은 name 속성이 있는 <a> 요소만 반환합니다.
<a> 요소의 이름 속성은 HTML5에서 지원되지 않습니다.
대안
문서의 <a> 요소 수:
let num = document.getElementsByTagName("a").length;
첫 번째 <a> 요소의 내용:
let content = document.getElementsByTagName("a")[0].innerHTML;
통사론
document.anchors
매개변수
없음 |
반환 값
Type | Description |
Object | An HTMLCollection of all lt;a> elements in the document that have a name attribute. |