Is there a case insensitive jQuery :contains selector?

后端 未结 12 2132
悲哀的现实
悲哀的现实 2020-11-22 02:45

Is there a case insensitive version of the :contains jQuery selector or should I do the work manually by looping over all elements and comparing their .text() to my string?<

12条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 03:12

    As of jQuery 1.3, this method is deprecated. To get this to work it needs to be defined as a function:

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

提交回复
热议问题