Skip to content

Instantly share code, notes, and snippets.

@victorono
Created November 25, 2013 01:58
Show Gist options
  • Save victorono/7635119 to your computer and use it in GitHub Desktop.
Save victorono/7635119 to your computer and use it in GitHub Desktop.
All attributes element jQuery
(function(old) {
$.fn.attr = function() {
if(arguments.length === 0) {
if(this.length === 0) {
return null;
}
var obj = {};
$.each(this[0].attributes, function() {
if(this.specified) {
obj[this.name] = this.value;
}
});
return obj;
}
return old.apply(this, arguments);
}
})($.fn.attr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment