From c9e510644a1fc2a7dd129756305d7ef56d05a39d Mon Sep 17 00:00:00 2001 From: Masahiro FUJIMOTO Date: Wed, 7 Apr 2021 00:57:38 +0900 Subject: DOMTokenList.length を新規翻訳 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2021/02/20 時点の英語版に基づき新規翻訳 --- files/ja/web/api/domtokenlist/length/index.html | 67 +++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 files/ja/web/api/domtokenlist/length/index.html (limited to 'files/ja/web') diff --git a/files/ja/web/api/domtokenlist/length/index.html b/files/ja/web/api/domtokenlist/length/index.html new file mode 100644 index 0000000000..ef56427191 --- /dev/null +++ b/files/ja/web/api/domtokenlist/length/index.html @@ -0,0 +1,67 @@ +--- +title: DOMTokenList.length +slug: Web/API/DOMTokenList/length +tags: +- API +- DOM +- DOMTokenList +- Property +- Reference +- length +translation_of: Web/API/DOMTokenList/length +--- +

{{APIRef("DOM")}}

+ +

length は {{domxref("DOMTokenList")}} インターフェイスの読み取り専用プロパティで、オブジェクト内に格納されたオブジェクトの個数を表します。

+ +

構文

+ +
tokenList.length;
+ +

+ +

integer です。

+ +

+ +

次の例は、 {{htmlelement("span")}} 要素に設定されたクラスのリストを {{domxref("Element.classList")}} を使用して DOMTokenList として取得し、そのリストの長さを <span> の {{domxref("Node.textContent")}} の中に書き込みます。

+ +

最初に HTML です。

+ +
<span class="a b c"></span>
+ +

そして JavaScript です。

+ +
let span = document.querySelector("span");
+let classes = span.classList;
+let length = classes.length;
+
+span.textContent = `classList length = ${length}`;
+
+ +

出力結果は以下のようになります。

+ +

{{ EmbedLiveSample('Examples', '100%', 60) }}

+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('DOM WHATWG','#dom-domtokenlist-length','length')}}{{Spec2('DOM WHATWG')}}初回定義
+ +

ブラウザーの互換性

+ +

{{Compat("api.DOMTokenList.length")}}

-- cgit v1.2.3-54-g00ecf