Hi,
Aber es geht auch so:
for(i=0; i < arrSubMenu.length; i++ )
{
if(arrSubMenu[i] == strSubID)
{
document.getElementById(arrSubMenu[i]).style.backgroundColor = "#e3e3e3";
document.getElementById(arrSubMenu[i]).style.fontWeight = "bold";
...
}
else
{
document.getElementById(arrSubMenu[i]).style.backgroundColor = "#F5F7F4";
document.getElementById(arrSubMenu[i]).style.fontWeight = "normal";
...
}
}
oder gar
for(i=0; i < arrSubMenu.length; i++ )
{
var obj = document.getElementById(arrSubMenu[i]);
if (obj != null)
{
if(arrSubMenu[i] == strSubID)
{
obj.style.backgroundColor = "#e3e3e3";
obj.style.fontWeight = "bold";
//...
}
else
{
obj.style.backgroundColor = "#F5F7F4";
obj.style.fontWeight = "normal";
//...
}
}
}
Das vermeidet das mehrfache Auswerten von document.getElementById - da wurde doch erst vor kurzem hier im Forum festgestellt, daß es "teuer" ist (und prüft auch noch, ob das Element mit der id überhaupt existiert).
cu,
Andreas
MudGuard? Siehe http://www.Mud-Guard.de/
Fachfragen per E-Mail halte ich für unverschämt und werde entsprechende E-Mails nicht beantworten. Für Fachfragen ist das Forum da.