【发布时间】:2012-12-30 15:58:40
【问题描述】:
我有一个变量,它存储带有一些内容的表格行。我想使用 %%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();
});
}
问题似乎出在过滤器部分,我无法弄清楚如何以其他方式解决。
【问题讨论】:
-
可能,但我对正则表达式不太熟悉:(
标签: jquery regex search filter