JQuery code :
<script type="text/javascript" language="javascript">
$(document).ready(function() {
// Initialise the table
$("#table-1 tbody tr:even").addClass("even");
$("#table-1 tbody tr:odd").addClass("odd");
$("#table-1 tbody tr td").addClass("BorderBottom");
$("#table-1 thead tr ").addClass("header");
$("#table-1 tbody tr").mouseover(function(){
$(this).addClass("over");
});
$("#table-1 tbody tr").mouseout(function(){
$(this).removeClass("over");
});
});
</script>
CSS Used :
.even
{
background-color:#C6DEFF;
}
.odd
{
background-color:#ffffff;
}
.BorderBottom
{
border-bottom:solid 1px blue;
text-align:center;
}
.over
{
background-color:#C6EEFF;
}
.header
{
background-color:Gray;
color:White;
}
The HTML Table
<table id="table-1" align="center" frame="vsides" width="70%" cellspacing="0" cellpadding="2">
<thead>
<tr>
<th>Col1</th><th>Col2</th><th>Col3</th>
</tr>
</thead>
<tbody>
<tr id="1">
<td>1</td><td>One</td><td>some text</td>
</tr>
<tr id="2">
<td>2</td><td>Two</td><td>some text</td>
</tr>
<tr id="3"><td>3</td><td>Three</td><td>some text</td>
</tr>
<tr id="4"><td>4</td><td>Four</td><td>some text</td>
</tr>
<tr id="5">
<td>5</td><td>Five</td><td>some text</td></tr>
<tr id="6">
<td>6</td><td>Six</td><td>some text</td>
</tr>
</tbody>
</table>
And we are done... below is the alternate colored row table with hover effect :
| Col1 | Col2 | Col3 |
|---|---|---|
| 1 | one | some text |
| 2 | two | some text |
| 3 | three | some text |
| 4 | four | some text |
| 5 | five | some text |
| 6 | six | some text |
No comments:
Post a Comment