Forum Moderators: not2easy
I was wondering how i could add onmouseover and onmouseout to the css of a table cell.
At the moment i use this code for each cell:
<td class="cell" onmouseover="style.backgroundColor='#FFFFFF';" onmouseout="style.backgroundColor='#EFEFF7'"></td>
I can't figure out how to use css to get same effect.
anyone?
thx in advance!
You are using CSS to a certain extent, but combined with Javascript.
In theory, you can use
td:hover to apply the desired effect, like this: td {background-color:#efeff7;}
td:hover {background-color:#fff;} In reality, Internet Explorer does not support
:hover on anything other than link anchors, so you are forced to use the Javascript solution you have already.
This allows you to use the CSS :hover attribute (as intended) in IE. yes it still requires js enabled, but the HTML code remains nice and neat (no typing js calls in there) the code all goes into the CSS file which links to the behaviour file..
Plus the added advantage that when/if future versions of IE ever start supporting it you can lessen the dependency on the behaviour file call.
Suzy