Skip to content

Instantly share code, notes, and snippets.

@TexRx
Forked from danheberden/finddata.jquery.js
Created November 27, 2013 06:49
Show Gist options
  • Save TexRx/7671623 to your computer and use it in GitHub Desktop.
Save TexRx/7671623 to your computer and use it in GitHub Desktop.
/*
* by Dan Heberden / 2011
* demo at http://jsfiddle.net/danheberden/VjKMY/
* made just for Elijah Manor
* e.g.
* $( 'div' ).findData( 'theDataKey', 'theValue' );
*
* will search in the divs and their children
*/
(function( $ ){
$.fn.findData = function( key, value ) {
var sel = '[data-' + key + '="' + value + '"]';
return this.find( sel ).add( this.filter( sel ) );
}
})( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment