我有一個變量,它存儲具有某些內容的錶行。我想使用%% LIKE %%方法搜索該字符串的特定術語,如果發現將該html行添加到僅包含已過濾行的新變量中。 如果可能,我希望搜索不區分大小寫。jQuery:在包含文本的字符串中查找標記
到目前爲止,我有以下的,這似乎不工作:
// 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();
});
}
的問題似乎是與過濾器的一部分,我無法弄清楚如何做到這一點任何其他方式。
正則表達式可能嗎? :) –
可能,但我不熟悉正則表達式:( –