I have a variable, which stores table rows with some content. I would like to search that string for a specific term using the %%LIKE%% approach and if found add this html row to a new variable containing filtered rows only.
If possible, I would like the search to be case insensitive.
So far I have the following, which doesn’t seem to work:
// 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();
});
}
The problem seem to be with the filter part and I cannot figure out how to do it any other way.
Try this:
Without the wrapping table tags i dont think jQuery will see it as a valid tag, as it has no root node.
UPDATE: The following code is working to add each matching row to the table #outTab, can you work with that to get to where you would like?