Skip to content

Instantly share code, notes, and snippets.

@8bitDesigner
Created July 24, 2014 23:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 8bitDesigner/ed78c06f7338067a49df to your computer and use it in GitHub Desktop.
Save 8bitDesigner/ed78c06f7338067a49df to your computer and use it in GitHub Desktop.
Get the difference in styles between two HTML nodes
function styleDelta(a, b) {
var aStyles = window.getComputedStyle(a)
, bStyles = window.getComputedStyle(b)
, delta = {}
Object.keys(aStyles).forEach(function(key) {
var aVal = aStyles[key]
, bVal = bStyles[key]
if (aVal != bVal) {
delta[key] = [aVal, bVal]
}
})
return delta
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment