pr0pensity
[H]ard|Gawd
- Joined
- Sep 2, 2003
- Messages
- 1,738
How do I make a table cell background change on hover and make it work in IE?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
buji You can do it with a combination of javascript and CSS.
How do you do that? Also I want to make the entire cell clickable, as in a hyperlink.maw said:you can't do it with CSS. it is pretty easy to do with Javascript though. if the javascript approach will work for you, let me know and i can whip up some code for ya.
<html>
<head>
<link rel="stylesheet" type="text/css" href="test.css" />
</head>
<body>
<table width="100%">
<tr class="a" onMouseOver="javascript:this.className='b'" onMouseOut="javascript:this.className='a'" onClick="javascript:window.location='http://www.test.com'"><td>test</td></tr>
<tr><td>test</td></tr>
</table>
</body>
</html>
.a
{
background-color:white;
}
.b
{
background-color:red;
}
.b
{
background-color:red;
cursor:pointer;
cursor:hand;
}
CSIXTY4 said:Also, you should have an actual link somewhere inside the TR just in case someone is surfing with JavaScript disabled or is using a screen reader or something like that.
<table>
<tr>
<td onClick="javascript:gotoURL('http://www.hardforum.com');" onMouseOver="javascript:this.className='b';" onMouseOut="javascript:this.className='a';"><a href="http://www.hardforum.com">Link</a></td>
</table>
doh said:Accessibility surrenders.![]()
CSIXTY4 said:The accessability problem lies in having the row/cell clickable to go to another URL.
CSIXTY4 said:The accessability problem lies in having the row/cell clickable to go to another URL.