/    Sign up×
Community /Pin to ProfileBookmark

var in function

Hi everyone !

I’ve a problem with javascript.
I’ve a function

[CODE]
function f(){
id = arguments[0];
left = ‘catleft’+id ;
}
[/CODE]

and i would like to do :

[CODE]
left.style.background=’red’ ;
[/CODE]

where left is my var, like : catleft12

Hope you can help me

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@cbVisionJul 14.2011 — So you want it to work like this?

[CODE]document.getElementById('catleft12').style.background = 'red';[/CODE]
Copy linkTweet thisAlerts:
@THT09authorJul 14.2011 — Exactly, but with my var ^^
Copy linkTweet thisAlerts:
@THT09authorJul 14.2011 — Oh ! Thank you ! It's really what i needed !

Thanks =D
×

Success!

Help @THT09 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...