Created
November 3, 2013 03:44
-
-
Save NV/7286433 to your computer and use it in GitHub Desktop.
Parse CSS in a browser
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
var style = document.createElement('style') | |
var iframe = document.createElement('iframe') | |
document.body.appendChild(iframe) | |
iframe.contentDocument.documentElement.appendChild(style) | |
iframe.style.display = 'none' | |
style.textContent = 'a {color: red}' | |
style.sheet // CSSStyleSheet | |
style.sheet.cssRules[0].cssText // 'a { color: red; }' | |
style.sheet.cssRules[0].selectorText // 'a' | |
style.sheet.cssRules[0].style[0] // 'color' | |
style.sheet.cssRules[0].style.color // 'red' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment