Last active
August 29, 2015 14:10
-
-
Save klauskpm/732310d0d3e10913162d to your computer and use it in GitHub Desktop.
Plugin to retrieve all attributes of a element
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
// jQuery Plugin - Loader | |
// | |
// Needs: | |
// - jQuery(2.1.1) >> http://code.jquery.com/jquery-2.1.1.js | |
(function($) { | |
/** | |
* Plugin to retrieve all attributes of a element | |
* @returns {Object} | |
*/ | |
$.fn.attrs = function(){ | |
var attributes = this.prop('attributes'), | |
retrivedAttributes = {}; | |
for(var x = 0; x<attributes.length; x++) { | |
retrivedAttributes[attributes[x].name] = attributes[x].value; | |
} | |
return retrivedAttributes; | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment