I'm looking for a solution to have a case-insensitive version of the :contains
selector in jQuery. I found these two posts here on Stack Overflow:
Is there a case insensitive jQuery :contains selector?
How do I make jQuery Contains case insensitive, including jQuery 1.8+?
So basically the solution is this:
jQuery.expr[':'].Contains = function(a,i,m){
return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0;
};
My only question is how do I use this? Where to I specify this piece of code?
I'm loading jQuery in my header and afterwards I load my script.js file where I have my DOM ready function declared. I put this piece of code outside the DOM ready function but it doesn't change anything in the behaviour of the :contains
selector.