Created
July 29, 2020 11:15
-
-
Save beatrizsmerino/92dcbd62ede69e84fe2a48be71e1db1a to your computer and use it in GitHub Desktop.
Get list of Css class use in the HTML file
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
function getListClassCss() { | |
let list = []; | |
let selectorsAll = document.querySelectorAll("[class]"); | |
selectorsAll.forEach((event) => { | |
let selectorClassAll = event.getAttribute("class").split(" "); | |
selectorClassAll.forEach( | |
(classCss) => { | |
if (classCss.length > 0 && list.indexOf(classCss) < 0) { | |
list.push(classCss) | |
}; | |
} | |
); | |
}); | |
let listOrdered = list.sort(); | |
return listOrdered; | |
} | |
let listClassCss = getListClassCss(); | |
console.info(listClassCss); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment