DOM

Node.firstChild プロパティ

 編集:2022.10.28 by T.A.

[Edge]。読取専用。→

Node の最初の子ノードを Node で返します。

mdn: Node が Document の場合は、その直接の子のリスト内の最初のノードを返します。

mdn: 子ノードがなければ null を返します。

構文
Node.firstChild
Node Node オブジェクト。

Node

HTML:

<SPAN id=IdTest>[SPAN要素。テキスト<B id=IdB>[B要素]</B>テキスト2<I id=IdI></I>]</SPAN><BR>

JavaScript:

D=IdTest.firstChild;
DA=IdI.firstChild;

得られた内容:D

=[object]:[object Text]
wholeText=[string]:[SPAN要素。テキスト
assignedSlot=[object]:null
splitText=[function]:function splitText() { [native code] }
data=[string]:[SPAN要素。テキスト
length=[number]:12
previousElementSibling=[object]:null
nextElementSibling=[object]:[object HTMLElement]
after=[function]:function after() { [native code] }
appendData=[function]:function appendData() { [native code] }
before=[function]:function before() { [native code] }
deleteData=[function]:function deleteData() { [native code] }
insertData=[function]:function insertData() { [native code] }
remove=[function]:function remove() { [native code] }
replaceData=[function]:function replaceData() { [native code] }
replaceWith=[function]:function replaceWith() { [native code] }
substringData=[function]:function substringData() { [native code] }
nodeType=[number]:3
nodeName=[string]:#text
baseURI=[string]:file:///C:/Users/asmin/Documents/HTML%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B・・・
isConnected=[boolean]:true
ownerDocument=[object]:[object HTMLDocument]
parentNode=[object]:[object HTMLSpanElement]
parentElement=[object]:[object HTMLSpanElement]
childNodes=[object]:[object NodeList]
firstChild=[object]:null
lastChild=[object]:null
previousSibling=[object]:null
nextSibling=[object]:[object HTMLElement]
nodeValue=[string]:[SPAN要素。テキスト
textContent=[string]:[SPAN要素。テキスト

得られた内容:DA

=[object]:null

テスト