javascript

Dom Element 관리

정보 집합 2020. 2. 11. 11:26
반응형

도큐먼트 = 문서

엘레먼트 = 태그

 

도큐먼트의 엘레먼트 = <html>xxxxx</html>  글 전부

var rootElement = document.documentElement;

 

 

1.셀렉트 관련

 

Document.createElement()주어진 태그명을 사용해 새로운 요소를 생성합니다.

Document.getElementsByClassName()주어진 클래스 이름을 갖는 요소의 목록을 반환합니다.

Document.getElementsByTagName()주어진 태그명을 갖는 요소의 목록을 반환합니다.

document.getElementById()주어진 ID를 가진 요소의 참조를 반환합니다.

document.querySelector()문서 내에서 주어진 선택자를 만족하는 첫 번째 Element를 반환합니다.

document.querySelectorAll()주어진 선택자를 만족하는 모든 요소의 NodeList를 반환합니다.

document.getElementsByName()주어진 이름을 갖는 요소의 목록을 반환합니다.

 

 

2.속성

Element.attributes 어트리뷰트

Element.classList 클래스 목록

Element.className 클래스이름

Element.id Is a DOMString representing the id of the element.

Element.innerHTML Is a DOMString representing the markup of the element's content.

Element.localName Read onlyA DOMString representing the local part of the qualified name of the element.

 

 

- 크기

Element.clientHeight Read onlyReturns a Number representing the inner height of the element.

Element.clientLeft Read onlyReturns a Number representing the width of the left border of the element.

Element.clientTop Read onlyReturns a Number representing the width of the top border of the element.

Element.clientWidth Read onlyReturns a Number representing the inner width of the element.

 

- 이벤트

   - 포커스

blur Fired when an element has lost focus.Also available via the onblur property.

focus Fired when an element has gained focus.Also available via the onfocus property

focusin Fired when an element is about to gain focus.

focusout Fired when an element is about to lose focus.

 

등등~~~~

 

 

 

 

 

출처

https://developer.mozilla.org/en-US/docs/Web/API/element

반응형