让jQuery的contains方法不区分大小写

// NEW selector  

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

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

//该代码片段来自于: http://www.sharejs.com/codes/javascript/4289 

用法:
$("div:contains('John')") 

Test HTML:
<div>john</div>  
<div>John</div>  
<div>hey hey JOHN hey hey</div> 

原文地址:https://www.cnblogs.com/apollokk/p/6713913.html