I have a bunch of table cells that are all the same class and all do the same thing when mouseover'ed and mouseout'ed. Can I put the onMouseOver, etc. info into the class in my stylesheet in some way?
- Tokes
| SitePoint Sponsor |
I have a bunch of table cells that are all the same class and all do the same thing when mouseover'ed and mouseout'ed. Can I put the onMouseOver, etc. info into the class in my stylesheet in some way?
- Tokes




You can call a different class based on the onMouseover event to change the properties of the <td>:
Is that what you're after?Code:<html> <head> <style> td { height: 50px; width: 200px; } td.on { background: blue; color: white; padding: 0px; border: 4px inset grey; } td.off { background: black; color: red; padding: 0px; border: 4px outset grey; } </style> </head> <body> <table><tr><td class="off" onmouseover="this.className='on';" onmouseout="this.className='off';">Queequeg</td></tr></table> </body> </html>
You can if you're willing to forego IE for the moment and use CSS2:Originally posted by Tokes
I have a bunch of table cells that are all the same class and all do the same thing when mouseover'ed and mouseout'ed. Can I put the onMouseOver, etc. info into the class in my stylesheet in some way?
- Tokes
This will change any tag with an "onmouseover" or an "onmouseout" event. Works in Mozilla and Opera (current versions).Code:[onmouseover] { text-decoration:none; } [onmouseout] { text-decoration:underline; }
--Vinnie
That's what im currently doing... thought there might be a better way...Originally posted by isotope235
Is that what you're after? [/B]
Obviously not unless I want to use CSS2...
Thanks anyway guys!
- Tokes
Bookmarks