StylePropertyMap:append() 方法

可用性有限

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

append() 方法是 StylePropertyMap 接口的一部分,它将传入的 CSS 值添加到具有给定属性的 StylePropertyMap 中。

语法

js
append(property, value)

参数

property(属性)

一个标识符,指示要添加的样式特性(例如:font、width、background color)。

value

给定属性应具有的值。

返回值

无(undefined)。

示例

此示例演示了如何使用 HTMLElement.attributeStyleMap 将额外的背景图像值添加到元素的 background-image 属性中。

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

// append another value to the background-image property set on the attribute
buttonEl.attributeStyleMap.append(
  "background-image",
  "linear-gradient(180deg, blue, black)",
);

规范

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

浏览器兼容性