StylePropertyMap:delete() 方法

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

StylePropertyMap 接口的 delete() 方法移除具有给定属性的 CSS 声明。

语法

js
delete(property)

参数

property(属性)

一个标识符,指示要移除的样式功能(例如,font、width、background color)。

返回值

无(undefined)。

示例

以下示例从元素的 style attribute 中移除 background-image 属性。

js
// get the button element
const buttonEl = document.querySelector("button");

// remove background-image from style attribute
buttonEl.attributeStyleMap.delete("background-image");

规范

规范
CSS 类型化 OM Level 1
# dom-stylepropertymap-delete

浏览器兼容性