Skip to content

Instantly share code, notes, and snippets.

@mavitm
Created July 10, 2016 18:20
Show Gist options
  • Save mavitm/ced729fa7107204ba8f7d615704d7ab8 to your computer and use it in GitHub Desktop.
Save mavitm/ced729fa7107204ba8f7d615704d7ab8 to your computer and use it in GitHub Desktop.
;(function($,undefined){
"use strict";
$.fn.getAttributes = function () {
var elem = this,
attr = {};
if(elem && elem.length) {
$.each(elem.get(0).attributes, function( v, n ) {
n = n.nodeName || n.name;
v = elem.attr(n);
if( v != undefined && v !== false ) attr[n] = v;
});
}
return attr
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment