// 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; );
Ažuriranje za rad za jQuery 1.8
$.expr(":").contains = $.expr.createPseudo(function(arg) ( return function( elem ) ( return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0; ); ));
S ovim na mjestu,
$("div:contains('John')")
bi odabrao sva tri elementa:
john John hey hey JOHN hey hey
Demo putem Pabla Fortesa.