鼠标划过时整行变色
方法1:
<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=#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>
方法2:
<script>
function overIt(o)
{ o.style.backgroundColor='red';}
function outIt(o)
{ o.style.backgroundColor='';}
</script>
<table border=1 width=400>
<tr bgColor=#222222 onmouseover="overIt(this)" onmouseout="outIt(this)"> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#333333 onmouseover="overIt(this)" onmouseout="outIt(this)"> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#444444 onmouseover="overIt(this)" onmouseout="outIt(this)"> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#555555 onmouseover="overIt(this)" onmouseout="outIt(this)"> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#666666 onmouseover="overIt(this)" onmouseout="outIt(this)"> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#777777 onmouseover="overIt(this)" onmouseout="outIt(this)"> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#888888 onmouseover="overIt(this)" onmouseout="outIt(this)"> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#999999 onmouseover="overIt(this)" onmouseout="outIt(this)"> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#aaaaaa onmouseover="overIt(this)" onmouseout="outIt(this)"> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#bbbbbb onmouseover="overIt(this)" onmouseout="outIt(this)"> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#cccccc onmouseover="overIt(this)" onmouseout="outIt(this)"> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#dddddd onmouseover="overIt(this)" onmouseout="outIt(this)"> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#eeeeee onmouseover="overIt(this)" onmouseout="outIt(this)"> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
<tr bgColor=#ffffff onmouseover="overIt(this)" onmouseout="outIt(this)"> <td>aaa</td><td>aaa</td><td>aaa</td><td>aaa</td></tr>
</table>
- 没有相关文章
- 没有评论