Reputation: 2752
This code doesn't find UPPERCASE
if searched for with lowercase uppercase
vise versa same for lowercase
, if searched for LOWERCASE
.
I was thinking of making the input and data-label to lowercase with jquery before searching, but how?
Can someone help, thanks
Upvotes: 2
Views: 160
Reputation: 9455
Replace line 14 by this:
var matched = $("ul li").filter(function() { return $(this).data('label').toLowerCase().indexOf(input.toLowerCase()) >= 0; });
And change the show()
/hide()
logic:
$('ul li').hide();
matched.show();
matched = matched.length;
This also eliminates the problem of someone entering ]
or some other special character - that would break the CSS rule in your code.
Upvotes: 2
Reputation: 27247
Here's an updated fiddle for you http://jsfiddle.net/jdmTZ/5/
Remove the data attribute and add it in code:
$('.filter li').each(function() {
$(this).attr('data-label', $(this).text().toLowerCase());
});
Then search by lowercased input
var input = $(this).val().toLowerCase();
Upvotes: 4