Skip to content

Instantly share code, notes, and snippets.

@albertywu
Created May 23, 2015 04:50
Show Gist options
  • Select an option

  • Save albertywu/5a82b9ac1cd18282330a to your computer and use it in GitHub Desktop.

Select an option

Save albertywu/5a82b9ac1cd18282330a to your computer and use it in GitHub Desktop.
Short snippet that returns an array of unique classes in the DOM
/* returns an array of unique classes in the DOM */
var getUniqueClasses = function() {
var elementArray = [].slice.call(document.querySelectorAll('*'));
return _(elementArray)
.pluck('classList')
.map(_.toArray)
.flatten()
.unique()
.value()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment