Autor |
Nachricht |
Fuzy
Threadersteller
Dabei seit: 14.01.2003
Ort: PW
Alter: -
Geschlecht:
|
Verfasst Mi 04.08.2010 10:40
Titel Farbwechsel Tabellenzeile |
 |
|
Hallo
folgendes Prob:
Ich habe eine Tabelle in die ich gern eine Lesehilfe per javascript einbauen möchte (changecolor on mouseover)
Ich aber verschiedene Zeilen Hintergrundfarben mit css definiert:
Logischerweise verschwindet bei der Zeile "dark" dann die richtige Hintergundfarbe. Kann ich das Script entsprechend ausbauen? Kann mir Jemand weiterhelfen?
Code: | table tbody tr.light{
color:#666666;
background-color:#F7F7F7;
}
table tbody tr.dark{
color:#666666;
background-color:#E8E8E8;
} |
Code: | <script type="text/javascript">
function ChangeColor(tableRow, highLight)
{
if (highLight)
{
tableRow.style.backgroundColor = '#F19100';
tableRow.style.color = '#ffffff';
}
else
{
tableRow.style.backgroundColor = '#F7F7F7';
tableRow.style.color = '#808080';
}
}
function DoNav(theUrl)
{
document.location.href = theUrl;
}
</script> |
HTML: Code: |
<tr class="light" onmouseover="ChangeColor(this, true);" onmouseout="ChangeColor(this, false);" onclick="DoNav('#');">
<tr class="dark" onmouseover="ChangeColor(this, true);" onmouseout="ChangeColor(this, false);" onclick="DoNav('#');"> |
|
|
|
|
 |
safer-print
Dabei seit: 11.03.2010
Ort: -
Alter: -
Geschlecht:
|
Verfasst Mi 04.08.2010 11:04
Titel
|
 |
|
Versuch's mal so:
Code: |
<script type="text/javascript">
function ChangeColor(tableRow, highLight) {
if (highLight) {
tableRow.style.backgroundColor = '#F19100';
tableRow.style.color = '#ffffff';
} else {
if (this.style.className == 'light') {
tableRow.style.backgroundColor = '#F7F7F7';
tableRow.style.color = '#666666';
} else {
tableRow.style.backgroundColor = '#E8E8E8';
tableRow.style.color = '#666666';
}
}
}
</script> |
|
|
|
|
 |
Anzeige
|
|
 |
Fuzy
Threadersteller
Dabei seit: 14.01.2003
Ort: PW
Alter: -
Geschlecht:
|
Verfasst Mi 04.08.2010 11:50
Titel
|
 |
|
safer-print hat geschrieben: | Versuch's mal so:
Code: |
<script type="text/javascript">
function ChangeColor(tableRow, highLight) {
if (highLight) {
tableRow.style.backgroundColor = '#F19100';
tableRow.style.color = '#ffffff';
} else {
if (this.style.className == 'light') {
tableRow.style.backgroundColor = '#F7F7F7';
tableRow.style.color = '#666666';
} else {
tableRow.style.backgroundColor = '#E8E8E8';
tableRow.style.color = '#666666';
}
}
}
</script> |
|
danke, leider funktioniert es nicht. Die Zeilen bleiben jetzt eingefärbt.
|
|
|
|
 |
snuwie
Dabei seit: 06.07.2010
Ort: -
Alter: -
Geschlecht:
|
Verfasst Mi 04.08.2010 12:37
Titel
|
 |
|
warum nicht mit css?
tr.dark:hover td { background-color: red; }
tr.light:hover td { background-color: yellow; }
|
|
|
|
 |
Fuzy
Threadersteller
Dabei seit: 14.01.2003
Ort: PW
Alter: -
Geschlecht:
|
Verfasst Mi 04.08.2010 21:49
Titel
|
 |
|
snuwie hat geschrieben: | warum nicht mit css?
tr.dark:hover td { background-color: red; }
tr.light:hover td { background-color: yellow; } |
jeee, genau das hab ich gesucht! Danke
ps: css find ich toll
|
|
|
|
 |
safer-print
Dabei seit: 11.03.2010
Ort: -
Alter: -
Geschlecht:
|
Verfasst Do 05.08.2010 22:18
Titel
|
 |
|
Hi snuwie, die CSS-Lösung ist genau das Richtige. Nur kurz der Vollständigkeit halber:
Es muss natürlich heißen: tableRow.style.className == 'light' und nicht this.style.className == 'light'
Code: | <script type="text/javascript">
function ChangeColor(tableRow, highLight) {
if (highLight) {
tableRow.style.backgroundColor = '#F19100';
tableRow.style.color = '#ffffff';
} else {
if (tableRow.style.className == 'light') {
tableRow.style.backgroundColor = '#F7F7F7';
tableRow.style.color = '#666666';
} else {
tableRow.style.backgroundColor = '#E8E8E8';
tableRow.style.color = '#666666';
}
}
}
</script> |
|
|
|
|
 |
|
|
 |
Ähnliche Themen |
Galerie mit Farbwechsel
automatischer Farbwechsel
Flash: farbwechsel bei Mausbewegung
|
 |