0
我需要过滤我的表格,因此它只使用所需的最小行数,例如,如果表格维度的宽度为5列,那么具有say 12结果的过滤器的结果应该有3行。我现在所拥有的只是过滤掉一排行,并留下行数太多的表格。Jquery过滤表格单元格
的jQuery:
$("#filter").keyup(function(){
// Retrieve the input field text and reset the count to zero
var filter = $(this).val(), count = 0;
// Loop through the comment list
$("td").each(function(){
// If the list item does not contain the text phrase fade it out
if ($(this).text().search(new RegExp(filter, "i")) < 0) {
$(this).hide();
// Show the list item if the phrase matches and increase the count by 1
} else {
$(this).show();
count++;
}
});
// Update the count
var numberItems = count;
$("#filter-count").text("Number of Comments = "+count);
});
$i++;
我期待的答案:]:[ – 2011-05-26 11:14:37