If statement 我怎么能';如果';docment.getElementById.style.background中的条件?
这是css代码。 我想设置div_wrap_p_bestgames的mouseout函数 如果条件为背景色#1B1C1EIf statement 我怎么能';如果';docment.getElementById.style.background中的条件?,if-statement,colors,background,document,If Statement,Colors,Background,Document,这是css代码。 我想设置div_wrap_p_bestgames的mouseout函数 如果条件为背景色#1B1C1E 此条件不起作用您需要使用下一行获取元素的背景色 document.getElementById(“div\u wrap\u p\u newgames”).style.backgroundColor 如果需要将其与特定值进行比较,请将十六进制代码转换为rgb值并进行比较 if(document.getElementById(“myDiv”).style.backgroundCo
此条件不起作用您需要使用下一行获取元素的背景色
document.getElementById(“div\u wrap\u p\u newgames”).style.backgroundColor
如果需要将其与特定值进行比较,请将十六进制代码转换为rgb值并进行比较
if(document.getElementById(“myDiv”).style.backgroundColor==“rgb(27,28,30)”)
rgb(28,27,30)相当于#1B1C1E
你好,世界!
这是一个div元素。
获取div的背景色
函数myFunction(){
if(document.getElementById(“myDiv”).style.backgroundColor==“rgb(27,28,30)”)
{
警报(“hi”);
}
}
.div_wrap_p_bestgames {
display: table;
width: 130px;
height: 40px;
float: left;
background: #1B1C1E;
position: relative;
margin-top: 150px;
margin-left: -100px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
function onMouseoutNewGames() {
if (document.getElementById("div_wrap_p_newgames").style.background == "#1B1C1E")
///do something
}