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 |
浏览器兼容性
加载中…