DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Michael has posted 27 posts at DZone. View Full User Profile

Table Row Hightlight On Mouseover

05.30.2007
| 1071 views |
  • submit to reddit
        // Highlight tale row on mouseover, based on tr row tag of table

<script type="text/javascript">

	function hiLiteRows(){
		var x = document.getElementsByTagName('tr');
		for (var i=0;i<x.length;i++)
		{
			x[i].onmouseover = function () {this.origColor=this.style.backgroundColor;
					this.style.backgroundColor='#D8E5F2';
			}
			x[i].onmouseout = function () {this.style.backgroundColor=this.origColor;}
		}
	}
	
	window.onload=hiLiteRows;

</script>