// 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; );
Актуализация, за да работи за jQuery 1.8
$.expr(":").contains = $.expr.createPseudo(function(arg) ( return function( elem ) ( return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0; ); ));
С това на място,
$("div:contains('John')")
ще избере и трите от тези елементи:
john John hey hey JOHN hey hey
Демо през Pablo Fortes.