当前位置: 代码迷 >> Java Web开发 >> JS兑现光棒效果
  详细解决方案

JS兑现光棒效果

热度:5854   发布时间:2013-02-25 21:10:13.0
JS实现光棒效果
1.当鼠标移动到该记录的时候编程蓝色
2.当鼠标移开的时候改记录编程默认颜色(比如白色)
3.当用户选中某一条记录的时候编程红色

var Color;
function mouse(obj, affair) {
if (affair == "onmouseover") {
Color = obj.style.backgroundColor;
obj.style.backgroundColor = "#6699ff";
}else if (affair == "onmouseout"){
obj.style.backgroundColor = Color;
}else{
obj.style.backgroundColor = "#FF0000";
}
}

求大神,

------解决方案--------------------------------------------------------
onmouseclick
------解决方案--------------------------------------------------------
HTML code
<script type="text/javascript">  <!--    var lastSelected;  //最后点击的元素    function over(obj){        obj.style.backgroundColor="red";    }    function out(obj){        if(obj == lastSelected )            obj.style.backgroundColor="green";        else            obj.style.backgroundColor="white";    }    function clicked(obj){        if(lastSelected != null)        {            lastSelected.style.backgroundColor="white";        }        lastSelected = obj;        obj.style.backgroundColor="green";    }  //-->  </script> </head> <body>  <table border="1">  <tr onmouseover="over(this)" onmouseout="out(this)" onclick="clicked(this)">    <td>1111</td>    <td>2222</td>    <td>3333</td>  </tr>  <tr onmouseover="over(this)" onmouseout="out(this)" onclick="clicked(this)">    <td>1111</td>    <td>2222</td>    <td>3333</td>  </tr>  </table> </body>
  相关解决方案