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