Skip to content

Instantly share code, notes, and snippets.

@bytefade
Created April 29, 2015 14:26
Show Gist options
  • Save bytefade/337e24305e0f0475aa31 to your computer and use it in GitHub Desktop.
Save bytefade/337e24305e0f0475aa31 to your computer and use it in GitHub Desktop.
Make jQuery :contains Case-Insensitive
// jquery > 1.8
$.expr[":"].contains = $.expr.createPseudo(function(arg) {
return function( elem ) {
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});
//---uso
$("div:contains('John')")
//---html
<div>john</div>
<div>John</div>
<div>hey hey JOHN hey hey</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment