jQuery 1.3 - Case Insensitive :contains()

Some thoughts scribbled down on Wednesday 04 March 2009 at 06:24 AM

Ran into a bit of an issue today when I upgraded the jQuery on a website I was working on to the new 1.3.2 version. I got the following error:

Object doesn't support this property or method.

There is a fix for this. You will need to update your jQuery extension code to the following:

$.extend($.expr[":"], {
    "containsNC": function(elem, i, match, array) {
        return (elem.textContent || elem.innerText || "").toLowerCase
().indexOf((match[3] || "").toLowerCase()) >= 0;
    }
});

Now all is peachy clean (although this new script seems to perform slower than the old one. I will see if I can optimize it)

Comments

Wed 04 Mar 2009 at 10:49 AM

Justin → http://kingjustin.com

Updating libraries on a client project midstream. Hmmm :)

Permalink

Sat 02 May 2009 at 4:19 AM

Alex Petrescu → http://www.kilometer0.com

Thanks! Saved me a few hours.

Permalink

Wed 04 Nov 2009 at 7:39 AM

Peter Allen → www.bitsofsharepoint.com

Great solution! Added into a filter solution for SharePoint and lists. Your code provided the best results!!!!

Thanks!!!

Permalink

Tue 29 Dec 2009 at 3:28 PM

Andrew Kuroedov

Thanks for solution! Works great!

Permalink

Post your comment