Indledning
mhaTable laver en mouseover effekt og alternative farver på tabelrækkerne ved hjælp af DOM'en. Scriptet er supporteret i IE5+, Opera7(*) og Netscape6/Mozilla.
(*) virker kun uden thead og tbody.
Eksempel
| Title | Artist | Company | Price |
|---|---|---|---|
| Empire Burlesque | Bob Dylan | Columbia | 10.90 |
| Hide your heart | Bonnie Tyler | CBS Records | 9.90 |
| Greatest Hits | Dolly Parton | RCA | 9.90 |
| Still got the blues | Gary Moore | Virgin records | 10.20 |
| Eros | Eros Ramazzotti | BMG | 9.90 |
Opsætning
For at opsætte mhaTable skal der linkes til javascriptet mhaTable.js
<script src="mhaTable.js" type="text/javascript"></script>
Ved eventen onload skal enten alt.alternateById(str) eller alt.alternateByClass(str) kaldes.
alt.alternateById(str) opsætter en tabel med et bestemt id.
alt.alternateByClass(str) opsætter samtlige tabeller med en bestemt class.
<script type="text/javascript">
<!--
function init() {
if (typeof alt != "undefined") {
if (alt.standards) {
// alt.alternateById("table1")
alt.alternateByClass("alternate")
}
}
}
window.onload = init;
//-->
</script>
Her er et eksempel på en tabel.
<table id="table1" class="alternate">
<thead>
<tr>
<th>Title</th>
<th>Artist</th>
<th>Company</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>Empire Burlesque</td>
<td>Bob Dylan</td>
<td>Columbia</td>
<td>10.90</td>
</tr>
<tr>
<td>Hide your heart</td>
<td>Bonnie Tyler</td>
<td>CBS Records</td>
<td>9.90</td>
</tr>
<tr>
<td>Greatest Hits</td>
<td>Dolly Parton</td>
<td>RCA</td>
<td>9.90</td>
</tr>
<tr>
<td>Still got the blues</td>
<td>Gary Moore</td>
<td>Virgin records</td>
<td>10.20</td>
</tr>
<tr>
<td>Eros</td>
<td>Eros Ramazzotti</td>
<td>BMG</td>
<td>9.90</td>
</tr>
</tbody>