Struppi: SRC bei IMG via getElementById ändern?

Beitrag lesen

hi Thomas

dank dir, aber so ganz mag das bei mir nicht klappen...besser gesagt: es funktioniert garnicht :( (winNT + IE 6)

das JS hab ich jetzt so wie du geschrieben hast mit getAttribute und setAttribut umgeschrieben, so das es jetzt so aussieht:

function plusminus(blubblub)
{
 if (document.getElementById(blubblub).getAttribute("src") == "plus.gif")
 {
  document.getElementById(blubblub).setAttribute("src","minus.gif");
 }
 else
 {
  document.getElementById(blubblub).setAttribute("src","plus.gif");
 }
}

die betreffende zeile im source code ist folgende:

<img src="plus.gif" width="18" height="18" alt="" border="0" id="ueberimg"><a href="#" onclick="plusminus('ueberimg'); return false;">&Uuml;bersicht</a>

Warum nicht so?
<img src="plus.gif" width="18" height="18" alt="" border="0" id="ueberimg">
<a href="#" onclick="plusminus(this); return false;">&Uuml;bersicht</a>

function plusminus(bild)
{
   if(bild.src == "plus.gif") bild.src = "minus.gif";
   else bild.src = "plus.gif";
}

Struppi.