Insensitive “contains”


You can actually change the behaviour of jQuery selector, for example, if you want “contains” to be insensitive, you can add this to your js file.

jQuery.expr[':'].contains = function(a, i, m) {
    return jQuery(a).text().toUpperCase()
        .indexOf(m[3].toUpperCase()) >= 0;
  };

Then in your jQuery code, you can target and hide everything that any div that contains “examPLE”, “EXampLE”, “example”…etc with the follow selector.

jQuery("div:contains('example')").hide();


Leave a Reply

Your email address will not be published.