--- title: CSSStyleDeclaration.removeProperty() slug: Web/API/CSSStyleDeclaration/removeProperty tags: - API - CSSOM - Method - Reference translation_of: Web/API/CSSStyleDeclaration/removeProperty ---
{{ APIRef("CSSOM") }}
CSSStyleDeclaration.removeProperty()
方法移除style对象的一个属性。
var oldValue = style.removeProperty(property);
property
是一个 {{domxref('DOMString')}} ,代表要移除的属性名。注意由多个单词组成的属性要用连字符连接各个单词,不接收驼峰命名法的形式。oldValue
是一个 {{domxref('DOMString')}} ,等于被移除的属性在移除前的属性值。下面的 JavaScript 代码从样式表里移除了 margin
属性:
var declaration = document.styleSheets[0].rules[0].style; var oldValue = declaration.removeProperty('margin');
Specification | Status | Comment |
---|---|---|
{{SpecName('CSSOM', '#dom-cssstyledeclaration-removeproperty', 'CSSStyleDeclaration.removeProperty()')}} | {{Spec2('CSSOM')}} | |
{{SpecName('DOM2 Style', 'css.html#CSS-CSSStyleDeclaration', 'CSSStyleDeclaration')}} | {{Spec2('DOM2 Style')}} |
{{CompatibilityTable}}
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
Feature | Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |