不区分大小写包含jQuery选择器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了不区分大小写包含jQuery选择器相关的知识,希望对你有一定的参考价值。

This one was not created by me, but I can't remember who originally created it. It does the same thing as the built in <code>:contains()</code> selector with one important difference, it's case insensitive. Since I usually type in all lower case (bad habit I know) I like to use it for filters. It's also a nice one to use on name filters, that way if the person using the filter doesn't use the proper case it will still pull of the name, for example if they type in "Delsoto", but the proper capitalization is "DelSoto" the default <code>:contains()</code> won't find it, but this modified <code>:Contains()</code> will. Very convient.

If you have any questions about this selector, or happen to know who made tit, post and let me know. Use it in a cool project, do the same.
  1. jQuery.expr[':'].Contains = function(a,i,m){
  2. return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0;
  3. };

以上是关于不区分大小写包含jQuery选择器的主要内容,如果未能解决你的问题,请参考以下文章

不区分大小写包含jQuery选择器

是否有不区分大小写的 jQuery :contains 选择器?

Jquery获取元素方法

Jquery都有哪些选择器

CSS 选择器对属性不区分大小写

Jquery获取元素方法