--- 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);

参数

返回值

异常

例子

下面的 JavaScript 代码从样式表里移除了 margin 属性:

var declaration = document.styleSheets[0].rules[0].style;
var oldValue = declaration.removeProperty('margin');

Specifications

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}}