大网数据广告活动
Web 标准与前端开发

MathMLElement: attributeStyleMap property

· 52CE 我爱测

The **`attributeStyleMap`** read-only property of the MathMLElement interface returns a live StylePropertyMap object that contains a list of style properties of the element that are defined in the element's inline `style` attribute, or assigned using the MathMLElement.style prope

CSSOM

The attributeStyleMap read-only property of the MathMLElement interface returns a live StylePropertyMap object that contains a list of style properties of the element that are defined in the element's inline style attribute, or assigned using the MathMLElement.style property of the MathMLElement interface via script.

Shorthand properties are expanded. If you set border-top: 1px solid black, the longhand properties (border-top-color, border-top-style, and border-top-width) are set instead.

The main difference between MathMLElement.style property and attributeStyleMap property is that, the style property will return a CSSStyleDeclaration object, while the attributeStyleMap property will return a StylePropertyMap object.

Though the property itself is not writable, you could read and write inline styles through the StylePropertyMap object that it returns, just like through the CSSStyleDeclaration object that returns via the style property.

Value

A live StylePropertyMap object.

Examples

The following code snippet shows the relationship between the style attribute and the attributeStyleMap property:

<math>
  <mrow>
    <mi>f</mi>
    <mo stretchy="false">(</mo>
    <mi id="el" style="border-top: 1px solid blue; color: red;">x</mi>
    <mo stretchy="false">)</mo>
    <mo>=</mo>
    <mi>x</mi>
  </mrow>
</math>
<div id="output"></div>
#el {
  font-size: 16px;
}

#output {
  white-space: pre-line;
}
const element = document.getElementById("el");
const output = document.getElementById("output");

for (const property of element.attributeStyleMap) {
  output.textContent += `${property[0]} = ${property[1][0].toString()}\n`;
}

Examples

Specifications

Browser compatibility

See also

  • MathMLElement.style
  • HTMLElement.attributeStyleMap
  • SVGElement.attributeStyleMap

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。