Not without CSS2 (as in !MSIE
). Need JS:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>untitled</title>
<style type="text/css">
th {
background: ghostwhite;
}
tr.out {
background: orange;
cursor: pointer;
}
tr.over {
background: darkorange;
cursor: pointer;
}
td {
font: 16px verdana;
color: #fff;
text-align: center;
}
</style>
<script type="text/javascript" language="javascript">
function setTR_onmouseovers() //register handlers
{
var row, rows, i = 0, feh = document.getElementById('feh');
rows = feh.rows;
while (row = rows.item(i++))
{
if (row.className == 'out') //all class="out" rows get this
{
row.onmouseover = function()
{
this.className = 'over';
}
row.onmouseout = function()
{
this.className = 'out';
}
row.onclick = function() //help yourself
{
alert('click');
}
}
}
}
onload = setTR_onmouseovers;
</script>
</head>
<body>
<form>
<table id="feh" cellspacing="2" cellpadding="4" border="1">
<thead>
<tr>
<th>header</th><th>header</th><th>header</th><th>header</th><th>header</th><th>header</th>
</tr>
</thead>
<tbody>
<script type="text/javascript" language="javascript">
var count = 1;
for (var iLoop = 0; iLoop < 8; ++iLoop) //saves space!
document.write (
'<tr class="out">' ,
'<td>cell ' + count++ + '</td><td>cell ' + count++ + '</td>' ,
'<td>cell ' + count++ + '</td><td>cell ' + count++ + '</td>' ,
'<td>cell ' + count++ + '</td><td>cell ' + count++ + '</td>' ,
'</tr>'
);
</script>
</tbody>
</table>
</form>
</body>
</html>
Note: this will only work if your table is named "feh".
Bookmarks