Skip to content

Instantly share code, notes, and snippets.

@IpsumLorem16
Last active January 9, 2019 10:26
Show Gist options
  • Save IpsumLorem16/eb1c185aa0df24cc4af49f3db673ec2a to your computer and use it in GitHub Desktop.
Save IpsumLorem16/eb1c185aa0df24cc4af49f3db673ec2a to your computer and use it in GitHub Desktop.
Gets all CSS classes in stylesheets and puts them into array Vanilla JS
let cssArray = [];
for (var i = 0; i < document.styleSheets.length; i++) {
var styleSheet = document.styleSheets[i];
for (var j = 0; j < 1; j++) {
let cssRules = styleSheet.cssRules;
for (var n = 0; n < cssRules.length; n++) {
cssArray.push(cssRules[n].selectorText);
}
}
}
console.log(cssArray + ' CSS Rules found');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment