How would I go about using an onMouseOver to change the background color of a cell in a table?
| SitePoint Sponsor |
How would I go about using an onMouseOver to change the background color of a cell in a table?





onMouseover="this.style.backgroundColor='#f90'". This'll work in NS 6 and IE 4+. For NS it takes some layers and ilayers, but check out my script that does exactly this: http://anarchos.xs.mw/crossmenu.phtml
Ah, I was using bgcolor. Thanks.![]()
is there a way to specify that in an external css file? I want a whole row to change color when the mouse moves over it, but I want to add it to the color specification for the row instead of addind tags in my code.





You can create a function that will do that. Then put the function into a .js file and link to it. Then, you can call the function and specify the color yo uwant to use right there...
Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes
I'm afraid that js is currently out of my realm of abilities. What I'm getting is that there is no easy way to take this:
<td class="yourclass" onMouseOver="this.className='yourotherclass';" onMouseOut="this.className='yourclass';">
and specify the mouseovers in "style.css"?




Your script should work for newer browsers.
Put something like this in your stylesheet:
HTHCode:td.yourclass { background:#000000; } td.yourotherclass { background:#003366; }
Bookmarks