Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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