0

Possible Duplicate:
Changing a CSS rule-set from Javascript

I know that there are no variables in CSS, but if it is possible to change body of CSS-listing on the page with JQ - it may be work around of this. Also, I know aboud addClass/removeClass, and css('blabla','blabla') JQ-methods, and it is not what I need.

Community
  • 1
  • 1
scythargon
  • 3,363
  • 3
  • 32
  • 62
  • That isn't a class, CSS doesn't have classes (it has class selectors, but that isn't what you are talking about). You want to change a rule-set (possibly one with a class selector). – Quentin Aug 15 '12 at 15:56
  • 1
    You could use it to append a new stylesheet to the dom, which could contain styles to overwrite the existing css. Although I can't imagine a good reason why you would need to do so? – Jeemusu Aug 15 '12 at 15:56
  • @Quentin thanks for correction, yes, I am talking about rule-set. – scythargon Aug 15 '12 at 16:10
  • @Jeemusu look: var color='black'; change_many_things = function(){ var style = document.createElement('style'); style.**content**+="body:{background:"+color+"}"; style.**content**+="other_element:{other_color_of_something:"+color+"}" document.getElementsByTagName('head')[0].appendChild(style); } – scythargon Aug 15 '12 at 16:14

1 Answers1

0

You can use a body class and then use CSS to manipulate only the class of body and then style everything based on your body class.

<body class="my-skin">
   <p>Lorem<p>
</body>

And in your CSS:

.my-skin p{color: red}
.my-skin img{border:2px solid #333;margin:5px}

.second-skin p{color:blue}

jQuery:

$('body').addClass('my-skin');
//or
$('body').removeClass('my-skin').addClass('second-skin');