CharacterData:length 屬性
只讀的 CharacterData.length 屬性返回包含資料中的字元數,為一個正整數。
值
一個正整數,表示 CharacterData.data 字串的長度。
示例
注意: CharacterData 是一個抽象介面。下面的示例使用實現了它的具體介面 Text。
html
Length of the string in the <code>Text</code> node: <output></output>
js
const output = document.querySelector("output");
const textNode = new Text("This text has been set using 'textNode.data'.");
output.value = textNode.length;
規範
| 規範 |
|---|
| DOM # dom-characterdata-length |
瀏覽器相容性
載入中…