aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/cssstyledeclaration/length/index.html
blob: 8da1caf745b90595e463d40f2ac93ebea49913c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
title: CSSStyleDeclaration.length
slug: Web/API/CSSStyleDeclaration/length
tags:
- API
- CSSOM
- Property
- Reference
browser-compat: api.CSSStyleDeclaration.length
translation_of: Web/API/CSSStyleDeclaration/length
---
<p>{{ APIRef("CSSOM") }}</p>

<p><span class="seoSummary">読み取り専用のプロパティで、この CSS 宣言ブロックにあるスタイル宣言の数を整数で表します。</span></p>

<h2 id="Syntax">構文</h2>

<pre
	class="brush: js">var <em>num</em> = <em>styles</em>.length;</pre>

<h3 id="Value"></h3>

<p>このインスタンスの親に明示的に設定されているスタイルの数を示す整数です。</p>

<h2 id="Example"></h2>

<p>次の例は、以下の HTML 要素に明示的に設定されたスタイルの数を取得します。
</p>

<pre
	class="brush: html">&lt;div id="div1" style="margin: 0 10px; background-color: #CA1; font-family: monospace"&gt;&lt;/div&gt;</pre>

<p>JavaScript コード:</p>

<pre>var myDiv = document.getElementById('div1'); var divStyle = myDiv.style; var len = divStyle.length; // 6</pre>

<h2 id="Specifications">仕様書</h2>

{{Specifications}}

<h2 id="Browser_compatibility">ブラウザーの互換性</h2>

<p>{{Compat}}</p>