ParentNode 믹스인mixin은 자식을 가질 수 있는 모든 종류의 Node 객체가 공통으로 가지는 메서드와 속성을 가집니다. Element, DocumentDocumentFragment 객체가 구현합니다.

선택자로 DOM 요소 선택하기 문서를 참고하여 CSS 선택자로 원하는 노드나 요소를 선택하는 법을 알아보세요.

속성

ParentNode.childElementCount Read only
ParentNode가 가진 자식 중 요소의 수를 반환합니다.
ParentNode.children Read only
ParentNode가 가진 모든 자식 중 요소만 모은 HTMLCollection을 반환합니다.
ParentNode.firstElementChild Read only
ParentNode의 자식이자 Element인 객체 중 첫 번째를 반환합니다. 만족하는 자식이 없으면 null을 반환합니다.
ParentNode.lastElementChild Read only
ParentNode의 자식이자 Element인 객체 중 마지막을 반환합니다. 만족하는 자식이 없으면 null을 반환합니다.

메서드

ParentNode.append()
ParentNode의 마지막 자식 다음에, 주어진 NodeDOMString 객체를 삽입합니다. DOMString 객체는 동등한 Text처럼 취급합니다.
ParentNode.prepend()
ParentNode의 첫 번째 자식 이전에, 주어진 NodeDOMString 객체를 삽입합니다. 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.

브라우저 호환성

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
ParentNodeChrome Full support 1Edge Full support YesFirefox Full support 3.5IE Full support 9Opera Full support 10Safari Full support 4WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
append
Experimental
Chrome Full support 54Edge Full support 17Firefox Full support 49IE No support NoOpera Full support 39Safari Full support 10WebView Android Full support 54Chrome Android Full support 54Firefox Android Full support 49Opera Android Full support 41Safari iOS Full support 10.2Samsung Internet Android Full support 6.0
childElementCountChrome Full support 1Edge Full support YesFirefox Full support 3.5IE Full support 9Opera Full support 10Safari Full support 4WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
childrenChrome Full support 1Edge Full support YesFirefox Full support 3.5IE Full support 9
Notes
Full support 9
Notes
Notes Internet Explorer 6, 7 and 8 supported it, but erroneously includes Comment nodes.
Opera Full support 10Safari Full support 4WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android ? Safari iOS Full support 9Samsung Internet Android Full support Yes
Support on Document and DocumentFragment
Experimental
Chrome Full support 29Edge ? Firefox Full support 25IE No support NoOpera Full support 16Safari No support NoWebView Android Full support YesChrome Android Full support YesFirefox Android ? Opera Android ? Safari iOS No support NoSamsung Internet Android Full support Yes
firstElementChildChrome Full support 1Edge ? Firefox Full support 3.5IE Full support 9Opera Full support 10Safari Full support 4WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
lastElementChildChrome Full support 1Edge Full support YesFirefox Full support 3.5IE Full support 9Opera Full support 10Safari Full support 4WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
prepend
Experimental
Chrome Full support 54Edge Full support 17Firefox Full support 49IE No support NoOpera Full support 39Safari Full support 10WebView Android Full support 54Chrome Android Full support 54Firefox Android Full support 49Opera Android Full support 41Safari iOS Full support 10Samsung Internet Android Full support 6.0
querySelectorAllChrome Full support 1Edge Full support YesFirefox Full support 3.5IE Full support 9
Notes
Full support 9
Notes
Notes Internet Explorer 8 only supported CSS2 selectors.
Opera Full support 10Safari Full support 4WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support 10.1Safari iOS Full support 3.2Samsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
See implementation notes.
See implementation notes.

같이 보기

문서 태그 및 공헌자

이 페이지의 공헌자: mdnwebdocs-bot, alattalatta, ExE-Boss
최종 변경자: mdnwebdocs-bot,