Skip to main content
1 of 2
jahu
  • 185
  • 9

Are there any jquery plugins for manipulating stylesheets?

Question moved from Stack Overflow since it's apparently offtopic there.

It appears people misunderstand the request. I'm perfectly aware that jquery has css() method which allows me to modify the style specified elements. However I want to modify rules within a stylesheet on the go. It has some legit uses which css() method cannot replace.

Something like:

<style id="dyn-style">
    p{ color:black; }
</style>
<p>TEST</p>
<script>
    $('#dyn-style').getCssRule('p').alterRule('color', 'red');
</script>

Which then changes the contents of the style to this:

<style id="dyn-style">
    p{ color:red; }
</style>

I searched a bit, but only found this. From what I understand it only adds new style elements (with defined styles) rather than alter existing ones.

I'm tempted to write a plugin of my own, but it would be pointless to do so if one exists already.

jahu
  • 185
  • 9