-
-
Save stan/1094138 to your computer and use it in GitHub Desktop.
filterByData jQuery Plugin
This file contains hidden or 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
// http://www.elijahmanor.com/2011/07/filterbydata-jquery-plugin.html | |
// https://gist.github.com/1048942 | |
(function($) { | |
/* by Elijah Manor with collaboration from Doug Neiner | |
* Filter results by html5 data attributes either at | |
* design or at runtime | |
* | |
* Usages: | |
* $( "p" ).filterByData( "mytype" ); | |
* $( "p" ).filterByData( "mytype, "mydata" ); | |
*/ | |
$.fn.filterByData = function( type, value ) { | |
return this.filter( function() { | |
var $this = $( this ); | |
return value != null ? $this.data( type ) === value : $this.data( type ) != null | |
}); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment