Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/463.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript IE8样式不支持setProperty方法_Javascript_Internet Explorer 8_Internet Explorer 7 - Fatal编程技术网

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”