Created
November 25, 2013 01:58
-
-
Save victorono/7635119 to your computer and use it in GitHub Desktop.
All attributes element jQuery
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) { | |
$.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