javascript - IE8风格不支持setProperty方法

标签 javascript internet-explorer-8 internet-explorer-7

在这行代码上出现此错误:

document.getElementsByTagName("table")[0].style.setProperty("background-color", "#D19000", "important");

enter image description here 对象不支持属性或方法“setProperty”

<小时/>

仅在 IE8 中,想想看,有人知道如何修复它吗?

最佳答案

对于旧版本的 Internet Explorer,您需要使用以下语法:

elem.style.backgroundColor = "#D19000";
elem.style.color = "red";

请注意,任何用连字符连接的属性都需要采用驼峰命名法。

关于javascript - IE8风格不支持setProperty方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58117039/

相关文章:

javascript - Ionic - 对具有不同内容的多个页面重复使用相同的 HTML 模板

javascript - 如何为将方法放在全局命名空间(窗口)上的库编写 Typescript 定义文件?

CSS - 将子div相对于其父级对齐,考虑父级填充

css - Ie6 和 Ie7 XHTML 严格的输入表单控件具有大量填充

javascript - Mootools Request() 每个 session IE9 只工作一次

javascript - slider 水平缩略图导航器大小和图像数量

javascript - jCarousel 下一个和上一个按钮,禁用?

javascript - 当我使用 equalHeights jQuery 插件时,IE8 返回 “object doesn' t support this property or method”

html - IE 固定位置对话框,慢速滚动 Div

html - ie7中的CSS位置