日期:2014-05-16  浏览次数:20296 次

onMouseOver对象问题
想问一下,如何用onMouseOver事件来做一下表格里面单行变色呢??

------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<html>
<head>
<title> New Document </title>
<meta name= "Generator " content= "EditPlus ">
<meta name= "Author " content= " ">
<meta name= "Keywords " content= " ">
<meta name= "Description " content= " ">
</head>

<body>

<table width=100% style= "border-collapse:collapse; table-layout:fixed " border >
<tr onmouseover= "this.style.background= '#DDDDDD ' " onmouseout= "this.style.background= 'blue ' ">
<td width=20% > &nbsp; </td> <td> &nbsp; </td>
</tr>
<tr onmouseover= "this.style.background= '#DDDDDD ' " onmouseout= "this.style.background= 'blue ' ">
<td width=20%> &nbsp; </td> <td> &nbsp; </td>
</tr>
<tr onmouseover= "this.style.background= '#DDDDDD ' " onmouseout= "this.style.background= 'blue ' ">
<td width=20%> &nbsp; </td> <td> &nbsp; </td>
</tr>
<tr onmouseover= "this.style.background= '#DDDDDD ' " onmouseout= "this.style.background= 'blue ' ">
<td width=20%> &nbsp; </td> <td> &nbsp; </td>
</tr>
<tr onmouseover= "this.style.background= '#DDDDDD ' " onmouseout= "this.style.background= 'blue ' ">
<td width=20%> &nbsp; </td> <td> &nbsp; </td>
</tr>
<tr>
<td width=20%> &nbsp; </td> <td> &nbsp; </td>
</tr>
</table>
</body>
</html>

------解决方案--------------------
自己分别给onmouseover\onmouseout写一个方法,参数就是tr的实例,
function mouseover(obj)
{
obj.bgcolor=red;
}
使用时
<tr onmouseover= "mouseover( '#DDDDDD '); " >
<td width=20%> &nbsp; </td> <td> &nbsp; </td>
</tr>
这样就好一些,注意代码的简单化