Skip to content

Instantly share code, notes, and snippets.

@alunny
Created March 12, 2011 20:53
Show Gist options
  • Save alunny/867552 to your computer and use it in GitHub Desktop.
Save alunny/867552 to your computer and use it in GitHub Desktop.
check which styles are different bw two html elements
// check which style properties are different between two DOM elements
// obv. needs a browser with getComputedStyle
function styleDiff(first, second) {
var oneStyle = getComputedStyle(first),
twoStyle = getComputedStyle(second),
diff = [],
i,
prop;
for (i = 0; i < oneStyle.length; i++) {
prop = oneStyle[i];
if (oneStyle[prop] != twoStyle[prop]) diff.push(prop);
}
return diff;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment