CSSStyleDeclaration.removeProperty()
CSSStyleDeclaration.removeProperty()
方法移除style对象的一个属性。
语法
var oldValue = style.removeProperty(property);
参数
property
是一个DOMString
,代表要移除的属性名。注意由多个单词组成的属性要用连字符连接各个单词,不接收驼峰命名法的形式。
返回值
oldValue
是一个DOMString
,等于被移除的属性在移除前的属性值。
异常
DOMException
NO_MODIFICATION_ALLOWED_ERR: 如果属性或声明块为只读,抛出此异常。
例子
下面的 JavaScript 代码从样式表里移除了 margin
属性:
var declaration = document.styleSheets[0].rules[0].style;
var oldValue = declaration.removeProperty('margin');
Specifications
Specification | Status | Comment |
---|---|---|
CSS Object Model (CSSOM) CSSStyleDeclaration.removeProperty() |
Working Draft | |
Document Object Model (DOM) Level 2 Style Specification CSSStyleDeclaration |
Obsolete |
浏览器支持情况
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |