My web site changes the CSS of some DOM elements when certain events occur, but I find it icky to have CSS in both my static CSS files and in my javascript files. Is there a good model that I can stick to that allows me to change the CSS of elements in javascript while not having explicit CSS in my javascript code?
Currently I’m using calls like:
$domElement.css ('cssProperty', 'cssValue');
in my javascript code, but I don’t want to do that since the CSS info should be in its own file.
What good options do I have?
I appreciate any help!
One option is to define different classes in your CSS file, then do this instead,
Of course, if you’re generating the
'cssValue'part of your example dynamically, then you can’t specify the CSS ahead of time, so you have no choice but to modify it directly with JavaScript as you are currently doing.