1. 개발자를 위한 웹 기술
  2. Web API
  3. Node
  4. Node.hasChildNodes()

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Node.hasChildNodes()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.

Node.hasChildNodes() 메소드는 현재 노드(Node)에게 자식노드(child nodes)가 있는지를 Boolean 값으로 반환합니다.

구문

js
node.hasChildNodes();

예시

아래 예시에서는 "foo"라는 id를 가진 요소를 찾고 "foo" 요소에게 자식노드가 있으면 첫번째 자식노드를 제거해줍니다.

js
var foo = document.getElementById("foo");
if (foo.hasChildNodes()) {
 foo.removeChild(foo.childNodes[0]);
}

명세

Specification
DOM
# ref-for-dom-node-haschildnodes1

같이 보기

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.

AltStyle によって変換されたページ (->オリジナル) /