首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

JS兑现光棒效果

2012-10-16 
JS实现光棒效果1.当鼠标移动到该记录的时候编程蓝色2.当鼠标移开的时候改记录编程默认颜色(比如白色)3.当

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> 

热点排行