|
Posted by BootNic on 02/24/06 16:24
> "Dave Smithz" <dave1900@blueyonder.co.uk> wrote:
> news:NRCLf.53819$DM.4683@fe3.news.blueyonder.co.uk....
>
> Hi there,
>
> I want to change the CSS style sheet applied to a table cell when
> the mouse moves over it. But I am not sure how to do it.
>
[snip]
>
> But it does not work. I know I can just use the following code in
> the function
> obj.style.backgroundColor='#FFFFFF';
> I have got this to work, but I do not want to hard code colours or
> anything like that. I want to keep them in stylesheets.
>
> Obviously the solution should be one that is cross browser
> compatible.
>
> Can anyone help?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript">
function hbob(){
var v=document.getElementById('bob').getElementsByTagName('tbody')[0].getElementsByTagName('td');
var x,i,j;
for (i=0, j=v.length; i<j; i++) {
x=v[i];
x.onmouseover=function(){this.className='highlight';};
x.onmouseout=function(){this.className='';};
}
}
if(document.getElementById &&
document.getElementsByTagName &&
(window.attachEvent || window.addEventListener))
{
frank=(window.attachEvent)?window.attachEvent('onload', hbob):
window.addEventListener("load", hbob, false);
}
</script>
<style type="text/css">
#bob{
margin: auto;
}
#bob tbody td{
background-color: #7FFFD4;
color: #A9A9A9;
}
#bob tbody td.highlight{
background-color: #FFFFE0;
color: #FF0000;
}
</style>
<title></title>
<meta http-equiv="content-type" content=
"text/html; charset=windows-1252">
</head>
<body>
<table id="bob" summary="" border="1">
<thead>
<tr><td colspan="2">My Table Head</td></tr>
</thead>
<tfoot><tr><td colspan="2">My Table Foot</td></tr></tfoot>
<tbody>
<tr><td>Row 1 Cell 1</td><td>Row 1 Cell 2</td></tr>
<tr><td>Row 2 Cell 1</td><td>Row 2 Cell 2</td></tr>
<tr><td>Row 3 Cell 1</td><td>Row 3 Cell 2</td></tr>
<tr><td>Row 4 Cell 1</td><td>Row 4 Cell 2</td></tr>
<tr><td>Row 5 Cell 1</td><td>Row 5 Cell 2</td></tr>
</tbody>
</table>
</body>
</html>
--
BootNic Friday, February 24, 2006 9:24 AM
All things come to him who waits - provided he knows what he is
waiting for.
*Woodrow T. Wilson*
Navigation:
[Reply to this message]
|