特定のニーズを満たすために、jQueryを使用して検索関数を最初から作成しました。<span>
のからデータを検索し、テキストボックス内の文字列と一致しない場合<div>
は非表示にします。<div>
私が抱えている問題は、文字列は認識しますが、最初の文字は認識しないことです。また、大文字と小文字が区別され、これは私が含めたい機能ではありません。
//Grab ID of current recordContainer
var currentID = $(this).attr('id');
// Add hash tag so it can be used as an ID call
var currentID2 = ("#" + currentID);
//Grab data from author span in current recordContainer
var currentAuthor = $(this).children('span.listLeadAuthor').text();
//If current author matches anything in the search box then keep it visible
if (currentAuthor.search(searchBox1) > 0)
{
$(currentID2).show();
count++;
}
//If search box is empty keep it visible
else if (searchBox1 === "")
{
$(currentID2).show();
}