Javascript IE8样式不支持setProperty方法
在这行代码中获取此错误:Javascript IE8样式不支持setProperty方法,javascript,internet-explorer-8,internet-explorer-7,Javascript,Internet Explorer 8,Internet Explorer 7,在这行代码中获取此错误: document.getElementsByTagName("table")[0].style.setProperty("background-color", "#D19000", "important"); 对象不支持属性或方法“setProperty” 只有在IE8中,如图所示,有人知道如何修复它吗?对于旧版本的Internet Explorer,您需要使用以下语法: elem.style.backgroundColor = "#D19000"; elem.st
document.getElementsByTagName("table")[0].style.setProperty("background-color", "#D19000", "important");
对象不支持属性或方法“setProperty”
只有在IE8中,如图所示,有人知道如何修复它吗?对于旧版本的Internet Explorer,您需要使用以下语法:
elem.style.backgroundColor = "#D19000";
elem.style.color = "red";
请注意,任何连字符的属性都需要在camelCase中。请尝试
。。。[0].style[“backgroundColor”]=“#D19000”
可以使用多边形填充CSSStyleDeclaration.prototype.setProperty=函数(名称、值、优先级){this[name]=value;}代码>如CSSStyleDeclaration
所示,请参见如何添加!backgroundColor的重要属性?如果我没有记错,您应该能够将其设置为:backgroundColor=“#D19000!important”
。