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 |
浏览器兼容性
加载中…