いくつかのコンテンツを含むテーブル行を格納する変数があります。%%LIKE%% アプローチを使用してその文字列を特定の用語で検索し、見つかった場合は、フィルタリングされた行のみを含む新しい変数にこの html 行を追加したいと思います。可能であれば、大文字と小文字を区別しない検索を希望します。
これまでのところ、次のようなものがありますが、うまくいかないようです:
// current list
var thisBlock = '<tr><td>Some content</td></tr><tr><td>Some other content</td></tr><tr><td>Even more content</td></tr>';
// new list
var thisList;
// phrase to be found
var thisValue = 'Some';
// filter
var thisItems = $(thisBlock).find("tr:contains('" + thisValue + "')");
// loop to append the found rows
if (thisItems !== '' && typeof thisItems !== 'undefined') {
$.each(thisItems, function() {
thisList += $(this).clone().wrap('<div>').parent().html();
});
}
問題はフィルター部分にあるようで、他の方法でそれを行う方法がわかりません。