我试图不区分大小写地使用“包含”大小写。我尝试在以下stackoverflow问题上使用该解决方案,但没有成功:
为了方便起见,将解决方案复制到此处:
jQuery.extend(
        jQuery.expr[':'], { 
                Contains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0" 
});
这是错误:
Error: q is not a function
Source File: /js/jquery-1.4.js?ver=1.4
Line: 81
这是我正在使用的地方:
  $('input.preset').keyup(function() {
    $(this).next().find("li").removeClass("bold");
    var theMatch = $(this).val();
    if (theMatch.length > 1){
      theMatch = "li:Contains('" + theMatch + "')";
      $(this).next().find(theMatch).addClass("bold");
    }
  });
在相同的情况下,我对原始区分大小写的“包含”的使用没有任何错误。有人有什么想法吗?我会很感激的。
:containsExact,:containsExactCase并且:containsRegex选择器现在可以在所有版本的jQuery中使用。