html javascript 这个颜色为什么会变成蓝色?

2025-03-13 18:08:04
推荐回答(4个)
回答1:

你在 if(odiv.style.... 的上面插入一行:

alert(odiv.style.background);
你就知道为什么了。

回答2:

我去问了一个前辈,他跟我说javascript读取到的是内联样式,gaibian()函数里,if条件里的odiv.style.background并没有读取到中.box {background: red;}里的red值,所以。。。。

回答3:

你alert(odiv.style.background);
一下弹出的必然是rgb的颜色,所以你判断背景肯定不为 red 就走了else

回答4:

把odiv.style.background写出来看看就知道了
这里可以用odivstyle.backgroundColor这样