Skip to content

Instantly share code, notes, and snippets.

@ericjames
Created October 9, 2017 20:06
Show Gist options
  • Save ericjames/9ce22ff405abc8c547b99987a3d3a4e8 to your computer and use it in GitHub Desktop.
Save ericjames/9ce22ff405abc8c547b99987a3d3a4e8 to your computer and use it in GitHub Desktop.
JavaScript: Get all stylesheet rules
function getAllColors() {
for (var s in document.styleSheets) {
var stylesheet = document.styleSheets[s];
if (stylesheet.title == 'themecolors') {
var rule = stylesheet.cssRules[0] || stylesheet.rules[0];
// if (rule.style.color) {
// rule.style.color = "red"
// }
// if (rule.style.background) {
// rule.style.background = "black"
// }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment