Last active
December 13, 2015 21:38
-
-
Save andreiglingeanu/4978208 to your computer and use it in GitHub Desktop.
get object that contains attributes of 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
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