Hi there.
There's no built in function to do that, as there's not only one way, but a series of methods for manipulating the styles of an element. Try something like this, this is the way that I like the most cause it's non intrusive script:
-
window.onmouseover = Over;
-
-
function Over(e) {
-
var obj = e.target || window.event.srcElement;
-
if(obj.tagName == "TD") {
-
obj.style.background = "#ffc";
-
obj.onmouseout = Out;
-
}
-
}
-
-
function Out(e) {
-
var obj = e.target || window.event.srcElement;
-
if(obj.tagName == "TD") {
-
obj.style.background = "none";
-
}
-
}
-
This will make any td of any table "highlightable" when you hover the mouse on it.
If you want to make it only work on tables with a certain class name you'll then want to check the obj's class name, like this:
-
window.onmouseover = Over;
-
-
function Over(e) {
-
var obj = e.target || window.event.srcElement;
-
if(obj.tagName == "TD") {
-
if(obj.className == "theClass") {
-
obj.style.background = "#ffc";
-
obj.onmouseout = Out;
-
}
-
}
-
}
-
-
function Out(e) {
-
var obj = e.target || window.event.srcElement;
-
if(obj.tagName == "TD") {
-
if(obj.className == "theClass") {
-
obj.style.background = "none";
-
}
-
}
-
}
-
Kind regards,
The_Nephilim
I'd like to know if there's a way to make the color of a cell/button change using onMouseOver. Is there some sort of "built-in" function to do this ?
Thank you....
p.s: If possible, the color should be random.