diff options
Diffstat (limited to 'files/zh-cn/web/api/cssstyledeclaration/removeproperty')
-rw-r--r-- | files/zh-cn/web/api/cssstyledeclaration/removeproperty/index.html | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/cssstyledeclaration/removeproperty/index.html b/files/zh-cn/web/api/cssstyledeclaration/removeproperty/index.html new file mode 100644 index 0000000000..b4437515b3 --- /dev/null +++ b/files/zh-cn/web/api/cssstyledeclaration/removeproperty/index.html @@ -0,0 +1,125 @@ +--- +title: CSSStyleDeclaration.removeProperty() +slug: Web/API/CSSStyleDeclaration/removeProperty +tags: + - API + - CSSOM + - Method + - Reference +translation_of: Web/API/CSSStyleDeclaration/removeProperty +--- +<p>{{ APIRef("CSSOM") }}</p> + +<p><code>CSSStyleDeclaration.removeProperty()</code> 方法移除style对象的一个属性。</p> + +<h2 id="语法">语法</h2> + +<pre class="brush: js">var <em>oldValue</em> = <em>style</em>.removeProperty(<em>property</em>);</pre> + +<h3 id="参数">参数</h3> + +<ul> + <li><em><code>property</code></em> 是一个 {{domxref('DOMString')}} ,代表要移除的属性名。注意由多个单词组成的属性要用连字符连接各个单词,不接收驼峰命名法的形式。</li> +</ul> + +<h3 id="返回值">返回值</h3> + +<ul> + <li><code><em>oldValue</em></code> 是一个 {{domxref('DOMString')}} ,等于被移除的属性在移除前的属性值。</li> +</ul> + +<h3 id="异常">异常</h3> + +<ul> + <li>{{domxref('DOMException')}} NO_MODIFICATION_ALLOWED_ERR: 如果属性或声明块为只读,抛出此异常。</li> +</ul> + +<h2 id="例子">例子</h2> + +<p>下面的 JavaScript 代码从样式表里移除了 <code>margin</code> 属性:</p> + +<pre class="brush: js">var declaration = document.styleSheets[0].rules[0].style; +var oldValue = declaration.removeProperty('margin'); +</pre> + +<h2 id="Specifications">Specifications</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-removeproperty', 'CSSStyleDeclaration.removeProperty()')}}</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> + +<h2 id="浏览器支持情况">浏览器支持情况</h2> + +<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> |