我有一个搜索功能,完全适用于我的应用程序,除了我无法弄清楚如何使它不区分大小写。以下是一些HTML的示例:
<div id='search_count'>
<div id='count'><?php get_count('notes', 'tasks') ?>
</div>
<input type="text" id='search_notes' placeholder='Search'/>
</div>
<div class='task'>
301 closet
</div>
<div class='notes'>
<p>The old manager opened a panel that needs to be closed.</p>
</div>
<div class='task'>vacuum halls </div>
<div class='notes'><p>The halls need to be vacuumed every week!</p></div>
这个JavaScript会像我想要的那样使用class ='notes'过滤div,但只是区分大小写。我怎么能不区分大小写呢?
$("#search_notes").keyup(function () {
var search_notes = $(this).val();
$('.task, .notes').css('display', 'none');
$("div.notes:contains(" + search_notes + ")")
.css('display', 'block')
.prev().css('display', 'block');
var count = $('div.notes').filter(function () {
return $(this).css('display') !== 'none';
}).length;
$('#count').text(count);
});
答案 0 :(得分:2)
您必须使用toLowerCase()方法测试两个小写值:
private fun symbols(): Single<SymbolContract.State> =
symbols.map<SymbolContract.State> { SymbolContract.State.Symbols(it) }
.onErrorReturnItem(SymbolContract.State.Error(SymbolContract.State.Error.Type.Network))