Created
April 3, 2012 00:41
-
-
Save jakebresnehan/2288330 to your computer and use it in GitHub Desktop.
Make jQuery :contains Case-Insensitive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 | |
// 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; | |
}; | |
$("div:contains('Jake')").css("text-decoration", "underline"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
jake without a capital J | |
</div> | |
<div> | |
Jake with a capital J | |
</div> | |
<div> | |
JAKE in Upper case | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment