単語を大文字にするかどうかを気にせずにリストをフィルタリングしようとしています。大文字と小文字を区別しないリストフィルタリング
私は次のようなHTMLがあります。ここでは
<ul class="dropdown-menu gatherDropDown" id="list">
<h3 id="header">Filter by </h3>
<input id="filter" type="text" name="fname" onkeyup="filterList(this)">
<li><input type="checkbox" class="item_name"> Producer 1</li>
<li><input type="checkbox" class="item_name"> Producer 2</li>
<li><input type="checkbox" class="item_name"> Producer 3</li>
<li><input type="checkbox" class="item_name"> Producer 4</li>
<li><input type="checkbox" class="item_name"> Producer 5</li>
<li><input type="checkbox" class="item_name"> Producer 6</li>
<li><input type="checkbox" class="item_name"> Producer 7</li>
</ul>
は私のjQueryのです:
function filterList(element){
var value = $(element).val();
$("#list > li:not(:contains(" + value + "))").hide();
$("#list > li:contains(" + value + ")").show();
}
私もcodepenを設定している:http://codepen.io/tetonhiker/pen/Nbqrzd
これを使用することができますか?もしそうなら、多分何かが助けることができるでしょうか? https://codepen.io/Aer0/pen/GNJqzo – Aer0
が動作しますが、一度入力テキストエリアからテキストを削除すると、元のリストは表示されません。どのように私は再びそれを表示することができますか? – lostInTheTetons
Side-remark:HTMLが無効です。 'ul'タグの直下に' input'タグも 'h3'タグも置かないでください。 – Mikey