Created
September 30, 2011 03:48
-
-
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
This file contains 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
$.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; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, that does look more attractive.