Skip to content

Instantly share code, notes, and snippets.

@andreiglingeanu
Last active December 13, 2015 21:38
Show Gist options
  • Save andreiglingeanu/4978208 to your computer and use it in GitHub Desktop.
Save andreiglingeanu/4978208 to your computer and use it in GitHub Desktop.
get object that contains attributes of an element
function outputAttributes (element) {
var pairs = {},
attrName,
attrValue,
i,
len;
for ( i = 0, len = element.attributes.length; i < len; i++ ) {
attrName = element.attributes[i].nodeName;
attrValue = element.attributes[i].nodeValue;
pairs[attrName] = attrValue;
}
return pairs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment