Skip to content

Instantly share code, notes, and snippets.

@dustinpoissant
Created January 31, 2017 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustinpoissant/b26a677ad21d761fe36fe76a23b74ed7 to your computer and use it in GitHub Desktop.
Save dustinpoissant/b26a677ad21d761fe36fe76a23b74ed7 to your computer and use it in GitHub Desktop.
Get all attributes of an element.
$.fn.attrs = function(){
var attributes = {};
if(this.length){
$.each( this[0].attributes, function( index, attr ) {
attributes[ attr.name ] = attr.value;
});
}
return attributes;
};
$.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