Last active
August 29, 2015 14:13
-
-
Save wayspurrchen/c688b2d9685418901791 to your computer and use it in GitHub Desktop.
Grab and list all (unique) classes on page
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 cls = []; | |
Array.prototype.slice.call( document.querySelectorAll('*'), 0 ).forEach( function ( el ) { | |
cls = cls.concat( Array.prototype.slice.call( el.classList, 0 ) ); | |
} ); | |
cls = cls.reduce( function ( p, c ) { | |
if ( p.indexOf( c ) < 0 ) p.push( c ); | |
return p; | |
}, [] ); | |
console.log( cls ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment