I need to filter a list according to a search string. The whole thing must be case-insensitive.
As you can see in the snippet, the i
flag for case-insensitivity works in a normal Jquery selector, but not in the filter selector. Is this a bug or is there something wrong with my code?
var searchString = 't';
// WORKS
$('li[data-number*="' + searchString + '" i]').css('border', '1px solid red');
// SAME SELECTOR BUT DOESN'T WORK
$('li').filter('li[data-number*="' + searchString + '" i]').css('background', 'lightcoral');
<ul>
<li data-number="One">First</li>
<li data-number="Two">Second</li>
<li data-number="Three">Third</li>
<li data-number="Four">Fourth</li>
</ul>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>