StylePropertyMap:clear() 方法

可用性有限

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

StylePropertyMap 接口的 clear() 方法移除 StylePropertyMap 中的所有声明。

语法

js
clear()

参数

无。

返回值

无(undefined)。

示例

以下示例移除了元素 style 属性中的所有样式。

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

// remove all styles from the style attribute
buttonEl.attributeStyleMap.clear();

规范

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

浏览器兼容性