萬盛學電腦網

 萬盛學電腦網 >> 腳本專題 >> javascript >> js代碼-鼠標劃過時整行變色

js代碼-鼠標劃過時整行變色

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<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='#71BAF0';
       the_obj.style.color='';
   }
}
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>

</head>
  
  <body>
<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>
</table>
  </body>
</html>
copyright © 萬盛學電腦網 all rights reserved