-
-
Save niittymaa/d3a5cc1b82d4aeae5b22974d7316dd14 to your computer and use it in GitHub Desktop.
Get all CSS attributes for an element.
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 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