当前位置:首页> 编程笔记> JS/JQuery
关键字
文章内容
鼠标移动到一项数据,更改该项数据背景颜色
 
 
修改时间:[2012/06/10 01:42]    阅读次数:[1543]    发表者:[起缘]
 

在网页上显示报表或列表时会查看一行,如果暂时更改这一行的背景颜色,就能使用户更方便查看数据,增强用户体验。

现给出代码,比较简单哈,不做说明了:

方法一

<script language="javascript">
	function ChangNewColor(obj){
		obj.style.backgroundColor = "#00ff00"
	}
	function ChangOldColor(obj){
		obj.style.backgroundColor="";
	}
</script>
<table width="100%%" border="1" cellspacing="1" cellpadding="1" bgcolor="#00ff00">
	<tr onmouseout="ChangNewColor(this)" onmouseover="ChangOldColor(this)" >
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<tr onmouseout="ChangNewColor(this)" onmouseover="ChangOldColor(this)" >
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<tr onmouseout="ChangNewColor(this)" onmouseover="ChangOldColor(this)" >
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<tr onmouseout="ChangNewColor(this)" onmouseover="ChangOldColor(this)" >
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<tr onmouseout="ChangNewColor(this)" onmouseover="ChangOldColor(this)" >
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<tr onmouseout="ChangNewColor(this)" onmouseover="ChangOldColor(this)" >
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
</table>
方法二
<tr onmouseover=\"this.style.backgroundColor='#999999'\" onmouseout=\"this.style.backgroundColor=''\">