[Edge]。→、、
CharacterData のテキスト データの値を表す文字列を返します。
mdn: 現在のオブジェクトのデータの値を表します。
CharacterData | ¶Text、Comment、CDATASection、ProcessingInstruction。 |
---|
文字列。
以下の例はこの抽象インターフェイスを実装した 2 つの具象インターフェイス、Text と Comment を使用しています。
HTML:
<!-- This is an HTML comment !--> <output id="Result"></output>
JavaScript:
let comment = document.body.childNodes[1]; let output = document.getElementById("Result"); output.value = comment.data;
HTML:
<SPAN id=IdTest>[SPAN要素。テキスト1<!--[コメント。テキスト2]-->テキスト3<B>[B要素。テキスト4]</B>テキスト5]</SPAN>
JavaScript:
NL=IdTest.childNodes; //IdTest の子ノード リストを得る。 //=[object]:[object NodeList] //0=[object]:[object Text] //1=[object]:[object Comment] //2=[object]:[object Text] //3=[object]:[object HTMLElement] //4=[object]:[object Text] //entries=[function]:function entries() { [native code] } //… D=NL[0]; //=[object]:[object Text] //wholeText=[string]:[SPAN要素。テキスト1 //assignedSlot=[object]:null //splitText=[function]:function splitText() { [native code] } //data=[string]:[SPAN要素。テキスト1 //length=[number]:13 //… D=NL[1]; //=[object]:[object Comment] //data=[string]:[コメント。テキスト2] //length=[number]:12 //previousElementSibling=[object]:null //…