Thanks Robert. That code worked flawlessly.
-------Original Message-------
From: JavaScript HowTo
Date: Friday, February 07, 2003 10:24:25 AM
To: JavaScript HowTo
Subject: [javascript_howto] RE: Highlighting a table cell with a universal
function
That's the way to go (with CSS).
There's not any problem highlighting cells with a mouseOver
event on the TABLE tag.
However, to make them go back to their original color is a bit more
tricky.
The best way to do this is to programmatically attach the events to
every table cell.
For instance, you can do it like this:
window.onload = function (){
var arrAllTDs = document.getElementsByTagName("td");
for(var i=0; i<arrAllTDs.length; i++){
arrAllTDs[i].onmouseover = function (){
this.style.backgroundColor = "navy";
this.style.color = "white";
}
arrAllTDs[i].onmouseout = function (){
this.style.backgroundColor = "white";
this.style.color = "navy";
}
}
}
/Robert
-----Original Message-----
From: Garrett Steed [mailto:gmsteed@s...]
Sent: den 7 februari 2003 15:46
To: JavaScript HowTo
Subject: [javascript_howto] RE: Highlighting a table cell with a
universal function
Have you tried using css?
-----Original Message-----
From: Trent Blackburn [mailto:puzzlepants@m...]
Sent: Friday, February 07, 2003 2:56 PM
To: JavaScript HowTo
Subject: [javascript_howto] Highlighting a table cell with a universal
function
Hi All,
I would like to know how to highlight any table cell that the user
hovers their mouse over with a single function that does not have to be
added in the individual cells or rows.
For instance, I would like something this:
<table border="0" width="100" onmouseover="javascript:highlightcell()">
The result is that this should highlight only one cell in the table, no
matter which cell the user puts their mouse over.
I don't know if this is possible, but maybe it can be done by
determining which cell the user has their mouse over, and then
highlighting that cell.
---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to