CharacterData: thuộc tính length
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Thuộc tính chỉ đọc CharacterData.length
trả về số lượng ký tự trong dữ liệu được chứa, dưới dạng một số nguyên dương.
Giá trị
Một số nguyên dương là độ dài của chuỗi CharacterData.data.
Ví dụ
Note:
CharacterData là một giao diện trừu tượng.
Các ví dụ dưới đây sử dụng Text, một giao diện cụ thể hiện thực nó.
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;
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| DOM> # dom-characterdata-length> |