Skip to content

Instantly share code, notes, and snippets.

@sixFingers
Created April 22, 2013 15:07
Show Gist options
  • Save sixFingers/5435782 to your computer and use it in GitHub Desktop.
Save sixFingers/5435782 to your computer and use it in GitHub Desktop.
Jquery plugin to select all elements with [data-*] attributes.
(function($) {
$.extend($.expr[":"], {
data: function(current, index, match, stack) {
for (var i = 0, attrs = current.attributes, l = attrs.length; i < l; i++) {
if((/\bdata-/g).test(attrs.item(i).nodeName)) return true;
}
return false;
}
})
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment