How do I highlight an entire row of a table on a mouseover event?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want the user to be able to highlight the entire row of a database driven
table no matter what column their mouse is ponted at. I know how to apply
DHTML events to individual cells of a table but I am having trouble trying to
apply it to the row.

Any help would be appreciated. Thanks in advance.
 
Hi,
Say you have a table like this
<table id="table1">
<tr><td>stuff</td><td>more stuff</td></tr>

You can either write the mouseover directly on the first row -
<tr onmouseover="this.style.backgroundColor='red';"><td>stuff</td><td>more
stuff</td></tr>
or you can attach it with script
function setMouse(){
var t = document.getElementById('table1').getElementsByTagName('tr');
t[0].onmouseover = function(){this.style.backgroundColor='red';}
}
onload=setMouse;

Both of these would do the same thing - make the first row red onmouseover
 
Back
Top