我有一个变量,它存储具有某些内容的表行。我想使用%% 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();
});
}
的问题似乎是与过滤器的一部分,我无法弄清楚如何做到这一点任何其他方式。
正则表达式可能吗? :) –
可能,但我不熟悉正则表达式:( –