Jutta: JavaScript Event Handler

Beitrag lesen

Hallo!

ich habe ein kleines Script geschrieben was folgendermaßen funktionieren soll:

Es gibt 3 Tabellen wenn ich über eine der Tabelle fahre ändert sich die Hintergrundfarbe, wenn ich in die Tabelle Klicke ändert sich erneut die die Hintergrundfarbe. Nur nun soll die Hintergrundfarbe auch beim mousout bestehen belieben solange der nächste klick kommt.

Wenn ich nun raus fahre ist wieder die alte Farbe da.

Ich habe hier schon alles ausprobiert aber keine hat funktioniert.

Ich habe hier mal mein Funktionierendes Script aufgelistet evtl. kann mir jemand sagen wie es richtig heißt?

gruss jutta

<script language="JavaScript">

function ChangeTxt(txt)
    {
        if(document.getElementById)
     {
           document.getElementById('lyr1').innerHTML = txt;

}
    }
   </script>

<table>
   <tr style="background: Silver;"
    onmouseover="this.style.cursor='hand' ; this.style.color='green' ; this.style.backgroundColor='#c6e4f4'"
    onmouseout="this.style.color='black' ; this.style.backgroundColor='Silver'"

onclick="ChangeTxt('text 1')
    ; this.style.color='#DCD444'">

<td>
   1111
   </td>
   </tr>
   </table>

<table>
   <tr style="background: #DCDCD6 background:;"
    onmouseover="this.style.cursor='hand' ; this.style.color='green' ; this.style.backgroundColor='#c6e4f4'"
    onmouseout="this.style.color='black' ; this.style.backgroundColor='#DCDCD6'"

onclick="ChangeTxt('text 2')
     ; this.style.color='#DCD444'">

<td>
   2222
   </td>
   </tr>
   </table>

<table>
   <tr style="background: Silver;"
    onmouseover="this.style.cursor='hand' ; this.style.color='green' ; this.style.backgroundColor='#c6e4f4'"
    onmouseout="this.style.color='black' ; this.style.backgroundColor='Silver'"

onclick="ChangeTxt('text 3')
    ; this.style.color='#DCD444'">

<td>
   3333
   </td>
   </tr>
   </table>

<div id="lyr1">
      <a href="#"> xxx </a>
   </div>