function cellOver()
{
// For simplicity, we assume there's only one possible class for the cell.
this.className = "over";
}
function cellOut()
{
// For simplicity, we assume there's only one possible class for the cell.
this.className = "";
}
function initCells()
{
var cells = document.getElementsByTagName("TD");
for (var n = 0; n < cells.length; n++)
{
// Better to use an addEvent variation here, but this is just an example.
// We add these event handlers to all cells on the page, even if some
// of them won't have the effect applied. This is not the most efficient,
// but it works, as long as the CSS only defines the "over" class for
// children of a "hovertable" class table.
cells[n].onmouseover = cellOver;
cells[n].onmouseout = cellOut;
}
}
// Better to use an addEvent variation here, but this is just an example)
window.onload = initCells;
|