Направите јКуери: садржи мала и мала слова - ЦСС-трикови

Anonim
// 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; );

Ажурирање ради за јКуери 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 

Демо путем Пабла Фортеса.