Created
October 6, 2011 13:55
-
-
Save hahmed/1267450 to your computer and use it in GitHub Desktop.
javascript ignore case filter
This file contains 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
// custom css expression for a case-insensitive contains() | |
$.expr[':'].Contains = function(a, i, m) { | |
return (a.textContent || a.innerText || "").toLowerCase().indexOf(m[3].toLowerCase()) >= 0; | |
}; | |
$(".search-box").keyup(function(e) { | |
//get current value | |
var that = $(this).val(); | |
if (that.length > 0) { //something exists | |
$(".listofitems .item") | |
.hide(); //hide all those that does not contain the input | |
$(".listofitems .item:Contains(" + that + ")") | |
.show(); //show all that contain the input | |
} | |
else { | |
$(".listofitems .item") | |
.show(); //nothing entered so show all items by default | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$('li', list).not($matches).slideUp();
$matches.slideDown();