ParentNode
믹스인mixin은 자식을 가질 수 있는 모든 종류의 Node
객체가 공통으로 가지는 메서드와 속성을 가집니다. Element
, Document
, DocumentFragment
객체가 구현합니다.
선택자로 DOM 요소 선택하기 문서를 참고하여 CSS 선택자로 원하는 노드나 요소를 선택하는 법을 알아보세요.
속성
ParentNode.childElementCount
Read onlyParentNode
가 가진 자식 중 요소의 수를 반환합니다.ParentNode.children
Read onlyParentNode
가 가진 모든 자식 중 요소만 모은HTMLCollection
을 반환합니다.ParentNode.firstElementChild
Read onlyParentNode
의 자식이자Element
인 객체 중 첫 번째를 반환합니다. 만족하는 자식이 없으면null
을 반환합니다.ParentNode.lastElementChild
Read onlyParentNode
의 자식이자Element
인 객체 중 마지막을 반환합니다. 만족하는 자식이 없으면null
을 반환합니다.
메서드
ParentNode.append()
ParentNode
의 마지막 자식 다음에, 주어진Node
나DOMString
객체를 삽입합니다.DOMString
객체는 동등한Text
처럼 취급합니다.ParentNode.prepend()
ParentNode
의 첫 번째 자식 이전에, 주어진Node
나DOMString
객체를 삽입합니다.DOMString
객체는 동등한Text
처럼 취급합니다.ParentNode.querySelector()
- 현재
ParentNode
를 기준으로, 하위 요소 중 주어진 선택자를 만족하는 첫 번째Element
를 반환합니다. ParentNode.querySelectorAll()
- 현재
ParentNode
를 기준으로, 하위 요소 중 주어진 선택자를 만족하는 모든 요소의NodeList
를 반환합니다.
명세
Specification | Status | Comment |
---|---|---|
DOM The definition of 'ParentNode' in that specification. |
Living Standard | Split the ElementTraversal interface into ChildNode and ParentNode . The ParentNode.firstElementChild , ParentNode.lastElementChild , and ParentNode.childElementCount properties are now defined on the latter. Added the ParentNode.children property, and the ParentNode.querySelector() , ParentNode.querySelectorAll() , ParentNode.append() , and ParentNode.prepend() methods. |
Element Traversal Specification The definition of 'ElementTraversal' in that specification. |
Obsolete | Added the initial definition of its properties to the ElementTraversal pure interface and used it on Element . |
브라우저 호환성
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
같이 보기
ChildNode
순수 인터페이스.