Skip to content

Instantly share code, notes, and snippets.

@shaneriley
Created February 21, 2012 16:28
Show Gist options
  • Save shaneriley/1877256 to your computer and use it in GitHub Desktop.
Save shaneriley/1877256 to your computer and use it in GitHub Desktop.
jQuery :data(#{selector}) expression
// Use:
// <input type="checkbox" data-accordion=".additional" />
// $(":data(accordion)").change(doSomething);
$.extend($.expr[":"], {
data: function(el, idx, selector) {
var attr = "data-" + selector[selector.length - 1];
return el.hasAttribute(attr);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment