• 회원가입
  • 로그인
  • 구글아이디로 로그인

[DOM_Document] JS - anchors 속성 - name 속성 갖은 모든 앵커태그집합 반환 (=anchors속성 = 앵커즈 속성)

목차

  1. anchors 예제 - name 속성 갖은 모든 앵커태그집합 반환
  2. anchors 정의
  3. anchors 구문
  4. anchors 소속 속성
  5. anchors 소속 메서드
  6. anchors 예제 - name 속성 갖는 첫 번째 <a> 접근

 

anchors 예제 - name 속성 갖은 모든 앵커태그집합 반환

 

<a href='https://homzzang.com/b/html'>HTML</a><br>

<a name="css" href='https://homzzang.com/b/css'>CSS</a><br>

<a name="php" href='https://homzzang.com/b/php'>PHP</a><br>

<a name="sql" href='https://homzzang.com/b/sql'>SQL</a><br>


<button onclick="homzzang()">클릭</button>


<p id="demo"></p>


<script>

function homzzang() {

  var x = document.anchors.length;

  document.getElementById("demo").innerHTML = x;

}

</script>

 

결과보기

결과값: 3

 

anchors 정의

 

name 속성 갖은 모든 <a> 태그 모음

 


 

1.

<a> 태그의 name 속성은 HTML5에서 지원 X.

 

2.

<a> 태그 모음 안의 요소들은 소스 코드에 있는대로 정렬.

 

3.

관련파트 : Anchor 객체 , document.links

 

4.

모든 브라우저 지원

 

anchors 구문

 

document.anchors

 


[반환값]

 

name 속성 갖는, 문서 안 모든 a 태그 집합인 HTMLCollection 객체 반환.

 

 

anchors 소속 속성

 

length

name 속성 갖는 <a> 요소 개수 반환. (읽기 전용)

 

 

anchors 소속 메서드

 

[index]

지정 색인번호의 name 속성 갖는 <a> 요소 반환.

※ 색인번호는 0부터 시작함.

※ 색인번호가 범위 밖일 때, null 반환.

 

item(index)

지정 색인번호의 name 속성 갖는 <a> 요소 반환.

※ 색인번호는 0부터 시작함.

※ 색인번호가 범위 밖일 때, null 반환.

 

namedItem(id)

지정 id 갖는 컬렉션에서 <a> 요소 반환.

※ 지정 id 비존재 시, null 반환.

 

 

anchors 예제 - name 속성 갖는 첫 번째 <a> 접근 

 

<a name="html">HTML 강의</a><br>

<a name="css">CSS 강의</a><br>

<a name="php">PHP 강의</a><br>


<button onclick="homzzang()">클릭</button>


<p id="demo"></p>


<script>

function homzzang() {

  var x = document.anchors[0].innerHTML;

  document.getElementById("demo").innerHTML = x;

}

</script>

 

결과보기 (결과값: HTML 강의)



분류 제목
DOM_Document JS - Document 객체 - 웹문서 객체의 속성/메서드 종류 (= document객체 = 다큐먼트객체)
DOM_Document JS - activeElement 속성 ★ - 현재포커스요소 반환 (= 액티브엘러먼트속성)
DOM_Document JS - addEventListener() 메서드 ★ - document에 이벤트 걸기. (= addEven…
DOM_Document JS - adoptNode() 메서드 ★ - 다른문서의 노드 잘라내서 가져오기 (IE9 이상) ※ 아이프레임…
DOM_Document JS - anchors 속성 - name 속성 갖은 모든 앵커태그집합 반환 (=anchors속성 = 앵커즈 …
DOM_Document JS - applets 속성 - 모든 애플릿태그집합 반환
DOM_Document JS - baseURI 속성 - 웹문서 기본URI 반환 (IE 지원X)
DOM_Document JS - body 속성 - 웹문서본문 설정/반환
DOM_Document JS - close() 메서드 - 웹문서출력모드 닫고 수집된 데이터 표시
DOM_Document JS - document.cookie 속성 ★ - (쿠키이름/쿠키값) 쌍을 설정/반환 (= document.…
DOM_Document JS - charset 속성 - 문자셋 (= 언어셋) 반환 (IE9 이상)
DOM_Document JS - characterSet 속성 - 문자셋 (= 언어셋) 반환 (IE9 이상)
DOM_Document JS - createAttribute() 메서드 ★ - 속성생성 (예: 클릭색상변경)
DOM_Document JS - createComment() 메서드 - 주석생성
DOM_Document JS - createDocumentFragment() 메서드 - 가상노드생성
DOM_Document JS - createElement() 메서드 ★ - 요소생성 (= createElement메서드 = 크리에이…
DOM_Document JS - createEvent() 메서드 - 이벤트객체생성 (예: 마우스오버횟수구하기)
DOM_Document JS - createTextNode() 메서드 - 텍스트노드생성
DOM_Document JS - defaultView 속성 - 윈도우객체 (Window Object)
DOM_Document JS - designMode 속성 - 편집기능 활성화 (= 디자인모드)
1/3
목록
찾아주셔서 감사합니다. Since 2012