Created
December 20, 2011 19:46
-
-
Save wulftone/1502947 to your computer and use it in GitHub Desktop.
Update a CSS Rule--(A Rule, as opposed to a CSS property of a rendered element)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://blog.hashtagify.me/2011/12/08/update-css-rules-with-5-lines-of-coffeescript/ | |
# http://jsfiddle.net/danmaz74/C7dv4/1/ | |
@updateCSS = (selector, styles) -> | |
for sheet in document.styleSheets | |
for rule in sheet.cssRules || sheet.rules || [] | |
if rule.selectorText == selector | |
for style, value of styles | |
rule.style[style] = value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment