//js中判断背景颜色的时候需要把HEX颜色转换成RGB格式
//以下代码中 #1173FD=rgb(17, 115, 253)
function color(e) {
if (e.style.backgroundColor == "rgb(17, 115, 253)") {e.style.backgroundColor = "#1173FD";
}
else {
e.style.backgroundColor = "#666666";
}
}
function color1(e) {
if (e.style.backgroundColor == "rgb(17, 115, 253)") {e.style.backgroundColor = "#1173FD";
}
else {
e.style.backgroundColor = "White";
}
}
//使用的时候如下代码 在div中我使用onmouseover和onmouseout两个事件来调用上面两个方法以做到移动鼠标改变div背景颜色的功能
<div style="font-size:15px;cursor:pointer;" οnclick="ShowPic(this,'<%=name%>')" οnmοuseοver="color(this)" οnmοuseοut="color1(this)"><%=data%></div>
之所以这样写是因为本人再点击事件里把div背景颜色改变为“蓝色”,在执行鼠标移动事件的时候不想把点击过的div背景颜色也修改掉。
发现此方法在IE下不起作用,各位有没有什么解决办法
本人希望经常积累一点,积少成多