/    Sign up×
Community /Pin to ProfileBookmark

Passing a variable in Javascript

Hi all,

I have a css file as below:

[CODE]
treechildren::-moz-tree-cell(makeItBlue00FF00)
{
background-color: blue;
}

[/CODE]

I am using the following line to append the css style to a tree cell

prop.AppendElement(aserv.getAtom(“makeItBlue00FF00”));

Everything works great, however I now wish to pass the color as a variable from javascript- this way I do not need to declare several styles in the CSS file. How can I do this? How do I modify the style sheet and how do I modify the Js to pass the variable.

Thanks

Kind regards

Chris

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@infinityspiralMay 07.2009 — I don't think you can pass variables to external css files. You can pass variables to styles defined on the page though. This example might be helpful:

http://www.tomhoppe.com/index.php/2008/03/dynamically-adding-css-through-javascript/
Copy linkTweet thisAlerts:
@Csam0003authorMay 07.2009 — Thanks alot for your promt reply.

Basically I dont want to create CSS through javascript.

I just wish to pass a variable between the external javascript file and the cSS file. This way I wont have to declare everyhting in CSS
×

Success!

Help @Csam0003 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 5.26,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...