Skip to content

Instantly share code, notes, and snippets.

@carymrobbins
Created August 23, 2014 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save carymrobbins/223de0b98504ac9bd654 to your computer and use it in GitHub Desktop.
Save carymrobbins/223de0b98504ac9bd654 to your computer and use it in GitHub Desktop.
Get all CSS attributes for an element.
var getCss = function(el) {
var style = window.getComputedStyle(el);
return Object.keys(style).reduce(function(acc, k) {
var name = style[k],
value = style.getPropertyValue(name);
if (value !== null) {
acc[name] = value;
}
return acc;
}, {});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment