---
title: "鼠标移动表格行上行变色的JS脚本"
author: "roses"
date: "2011-03-17T10:56:07Z"
tags: []
categories: ["Web前端"]
slug: "js"
draft: false
lastmod: "2011-03-17T10:56:07Z"
id: 965096
url: "https://roses.iteye.com/blog/965096"
---

<body>

<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='#444444';
	}
}

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 width="200" border="1"  onmouseover="overIt()" onmouseout="outIt()">
  <tr>
    <td >123</td>
	<td >123</td>
	<td >123</td>
  </tr>
  <tr>
    <td >123</td>
	<td >123</td>
	<td >123</td>
  </tr>
  <tr>
  <td >123</td>
	<td >123</td>
	<td >123</td>
  </tr>
</table>

</body>