Copy link to clipboard
Copied
hallo, was fuer klammern muss ich setzen ??
{gehe.menue_land_[i].visible = false;}
danke vorab
for (var i = 1; i <= 2; i++) {
if (i == 1) {
{gehe.menue_land_1.visible = true;}
} else
{gehe.menue_land_[i].visible = false;}
}
(
Hi.
To use bracket notation, put the fixed part of the name between quotes then add the variable part using the + operator. Like this:
for (var i = 1; i <= 2; i++)
{
if (i == 1)
{
gehe["menue_land_" + i].visible = true;
}
else
{
gehe["menue_land_" + i].visible = false;
}
}
Also, you have unneeded extra curly braces here:
{gehe.menue_land_1.visible = true;}
And as a bonus, your whole code could be written like this:
for (var i = 1; i <= 2; i++)
gehe["menue_land_" + i].visible = i
...
Danke !!!!
Funktioniert !!!
Copy link to clipboard
Copied
Hi.
To use bracket notation, put the fixed part of the name between quotes then add the variable part using the + operator. Like this:
for (var i = 1; i <= 2; i++)
{
if (i == 1)
{
gehe["menue_land_" + i].visible = true;
}
else
{
gehe["menue_land_" + i].visible = false;
}
}
Also, you have unneeded extra curly braces here:
{gehe.menue_land_1.visible = true;}
And as a bonus, your whole code could be written like this:
for (var i = 1; i <= 2; i++)
gehe["menue_land_" + i].visible = i == 1;
Please let us know if you have any further questions.
Regards,
JC
Copy link to clipboard
Copied
Danke !!!!
Funktioniert !!!
Copy link to clipboard
Copied
Excellent!
You're welcome!