Created
January 31, 2017 23:04
-
-
Save dustinpoissant/b26a677ad21d761fe36fe76a23b74ed7 to your computer and use it in GitHub Desktop.
Get all 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
$.fn.attrs = function(){ | |
var attributes = {}; | |
if(this.length){ | |
$.each( this[0].attributes, function( index, attr ) { | |
attributes[ attr.name ] = attr.value; | |
}); | |
} | |
return attributes; | |
}; |
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
$.fn.attrs=function(){var a={};return this.length&&$.each(this[0].attributes,function(b,c){a[c.name]=c.value}),a}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment