Skip to content

Instantly share code, notes, and snippets.

@wulftone
Created December 20, 2011 19:46
Show Gist options
  • Save wulftone/1502947 to your computer and use it in GitHub Desktop.
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)
# 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