jQuery contains大小写不敏感, Make jQuery :contains Case-Insensitive

 

//Code for overloading the :contains selector to be case insensitive:
//Without the overload on the :contains selector jquery would normaly only underline the second line

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

$("div:contains('Jake')").css("text-decoration", "underline");

 

 

本文: jQuery contains大小写不敏感, Make jQuery :contains Case-Insensitive

Leave a Reply