このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

CharacterData: length プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.

CharacterData.length プロパティは読み取り専用で、含まれているデータの文字数を正の整数で返します。

正の整数で、 CharacterData.data 文字列の長さを表します。

メモ: CharacterData は抽象インターフェイスです。 以下の例ではそれを実装した具象インターフェイスの一つである Text を使用しています。

html
<code>Text</code> ノード内の文字列の長さ: <output></output>
js
const output = document.querySelector("output");
const textnode = new Text(
  "このテキストは 'textnode.data' を使用して設定されました。",
);

output.value = textnode.length;

仕様書

Specification
DOM
# dom-characterdata-length

ブラウザーの互換性