在下面包含的代码中,脚本将打开和关闭div。风格
代码,控制要切换的div的父元素的背景色
开和关。该代码可在Opera中运行,但不能在Chrome中运行,而且我无法
研究(搜索)解决方案。
我当然可以继续写其他代码并实现我所需要的,但这有我的
现在开始好奇。
function CheckOutOpn(){
var Inny = document.getElementById("RightPaneASxOrderForm");
MVxCheckOutForm();
CDxButtonOpnChkOut();
MVxCLOSExBttnChkout();
Inny.style = "background-color:#332223;";
}
function CLOSExCheckOut(){
var Inny = document.getElementById("RightPaneASxOrderForm");
MVxButtonOpnChkOut();
CDxCLOSExBttnChkout();
CDxOrderFormItself();
Inny.style = "background-color:#33B32E;";
}
最佳答案
我认为您应该使用:
Inny.style.backgroundColor = "#332223";
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.style
...除了Opera中的样式外,无法通过将字符串分配给样式来设置样式
(只读)style属性,如elt.style =“ color:blue;”。这是
因为style属性返回CSSStyleDeclaration对象。