aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/cssstyledeclaration/item
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/cssstyledeclaration/item
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/cssstyledeclaration/item')
-rw-r--r--files/zh-cn/web/api/cssstyledeclaration/item/index.html117
1 files changed, 117 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/cssstyledeclaration/item/index.html b/files/zh-cn/web/api/cssstyledeclaration/item/index.html
new file mode 100644
index 0000000000..f3e5350ef9
--- /dev/null
+++ b/files/zh-cn/web/api/cssstyledeclaration/item/index.html
@@ -0,0 +1,117 @@
+---
+title: CSSStyleDeclaration.item()
+slug: Web/API/CSSStyleDeclaration/item
+translation_of: Web/API/CSSStyleDeclaration/item
+---
+<p>{{ APIRef("CSSOM") }}</p>
+
+<p id="Summary"><span class="seoSummary"><code>CSSStyleDeclaration.item()</code> 通过下标从 {{domxref('CSSStyleDeclaration')}} 返回一个 CSS 属性值</span>。只要传入参数这个方法就不会抛出异常; 当传入的下标越界时会返回空字符串,当未传入参数时会抛出一个 <code>TypeError</code> 。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">var <em>propertyName</em> = <em>style</em>.item(<em>index</em>);
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<ul>
+ <li><em><code>index</code></em> 是需要查找节点的索引,索引下标从零开始。</li>
+</ul>
+
+<h3 id="Return_value">Return value</h3>
+
+<ul>
+ <li><em><code>propertyName</code></em> 是一个 {{domxref('DOMString')}} ,是在特定索引位置下的属性的名称。</li>
+</ul>
+
+<p>使用以下的 javascript 语法可以通过索引从 style 的节点列表中获取对应值:</p>
+
+<pre class="syntaxbox">var propertyName = style[index];
+</pre>
+
+<h2 id="范例">范例</h2>
+
+<pre class="brush: js">var style = document.getElementById('div1').style;
+var propertyName = style.item(1); // or simply style[1] - returns the second style listed</pre>
+
+<h2 id="规范">规范</h2>
+
+<table>
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('CSSOM', '#dom-cssstyledeclaration-item', 'CSSStyleDeclaration.item()')}}</td>
+ <td>{{Spec2('CSSOM')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM2 Style', 'css.html#CSS-CSSStyleDeclaration', 'CSSStyleDeclaration')}}</td>
+ <td>{{Spec2('DOM2 Style')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<p><strong>浏览器兼容性</strong></p>
+
+<p>{{CompatibilityTable}}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <thead>
+ <tr>
+ <th scope="col">Feature</th>
+ <th scope="col">Chrome</th>
+ <th scope="col">Edge</th>
+ <th scope="col">Firefox (Gecko)</th>
+ <th scope="col">Internet Explorer</th>
+ <th scope="col">Opera</th>
+ <th scope="col">Safari (WebKit)</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Edge</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ <th>Chrome for Android</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>