鼠標劃過時整行變色284278過程講解

[html]<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>[/html]

推薦閱讀: