鼠标划过时整行变色

转载:脚本之家

<script>
function overIt(){
   var the_obj = event.srcElement;
   if(the_obj.tagName.toLowerCase() == "td"){
       the_obj=the_obj.parentElement;
       the_obj.oBgc=the_obj.currentStyle.backgroundColor;            the_obj.oFc=the_obj.currentStyle.color;
       the_obj.style.backgroundColor='red';
       the_obj.style.color='blue';
       the_obj.style.textDecoration='underline';
   }
}

function outIt(){
   var the_obj = event.srcElement;
   if(the_obj.tagName.toLowerCase() == "td"){
       the_obj=the_obj.parentElement;
       the_obj.style.backgroundColor=the_obj.oBgc;
       the_obj.style.color=the_obj.oFc;
       the_obj.style.textDecoration='';
   }
}

</script>


<table border=1 width=400 onmouseover="overIt()" onmouseout="outIt()">
<tr bgColor=#111111> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#222222> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#333333> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#444444> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#555555> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#666666> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#777777> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#888888> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#999999> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#aaaaaa> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#bbbbbb> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#cccccc> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#dddddd> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#eeeeee> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#ffffff> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
</table>
详细出处参考:http://www.jb51.net/article/12.htm

你可能感兴趣的:(.net,脚本)