Last active
August 29, 2015 14:01
-
-
Save jpgls/eb8c9b30c42ae7a64688 to your computer and use it in GitHub Desktop.
List All Class Names Used on Page
This file contains hidden or 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
// Temporary code for Development | |
var elements = document.getElementsByTagName('*'); | |
console.log('$$$$$ - Checked this many elements - ', elements.length); | |
var unique = function (list, x) { | |
if (x != "" && list.indexOf(x) === -1) { | |
list.push(x); | |
} | |
return list; | |
}; | |
var trim = function (x) { return x.trim(); }; | |
var classes = [].reduce.call(elements, function (acc, e) { | |
return e.className.split(' ').map(trim).reduce(unique, acc); | |
}, []); | |
console.log('$$$$$ - The Classes are - ', classes); |
This file contains hidden or 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 classArray = []; | |
$('*').each(function(){if(this.className!=""){classArray.push(this.className)}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment