Created
July 14, 2014 13:38
-
-
Save teddykishi/dfb4ddc8f2d8c89a8447 to your computer and use it in GitHub Desktop.
Get list of data attributes using with 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($) { | |
$.fn.allData = function(){ | |
var elements = [], data; | |
this.each(function(){ | |
data = $(this).data(); | |
elements.push(data); | |
}); | |
return this.length === 1 ? elements[0] : elements; | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment