Skip to content

Instantly share code, notes, and snippets.

@helloluis
Created September 30, 2011 03:48
Show Gist options
  • Save helloluis/1252589 to your computer and use it in GitHub Desktop.
Save helloluis/1252589 to your computer and use it in GitHub Desktop.
Mini-plugin for selecting elements with regex instead of an actual class name
$.fn.findClassWithRegex = function(regex) {
var results = [];
$(this).each(function(){
if ($(this).attr('class').length>0 && $(this).attr('class').match(regex)) {
results.push( this );
}
});
return results;
};
@helloluis
Copy link
Author

Thanks, that does look more attractive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment