Created
March 14, 2014 13:00
-
-
Save xarimanx/9547229 to your computer and use it in GitHub Desktop.
return all attr from jq object
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(old) { | |
jQuery.fn.attr = function() { | |
if(arguments.length === 0) { | |
if(this.length === 0) { | |
return null; | |
} | |
var obj = {}; | |
jQuery.each(this[0].attributes, function() { | |
if(this.specified) { | |
obj[this.name] = this.value; | |
} | |
}); | |
return obj; | |
} | |
return old.apply(this, arguments); | |
}; | |
})(jQuery.fn.attr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment