0

Possible Duplicate:
Is there a case insensitive jQuery :contains selector?

I tried to look everywhere online for a way to use the contains jQuery selector in a case-insensitive manner, but I couldn't really find any that actually functioned with the latest version of jQuery.

Thank you so much in advance!

Community
  • 1
  • 1

1 Answers1

2

Here's a custom implementation:

$.expr[':'].icontains = $.expr.createPseudo(function( text ) {
    text = text.toLowerCase();
    return function (el) {
        return ~$.text(el).toLowerCase().indexOf( text );
    }
});

Use it like this:

$(':icontains(SoMeThInG)');

Here's the fiddle: http://jsfiddle.net/CTg86/

Joseph Silber
  • 214,931
  • 59
  • 362
  • 292