2012-02-20 42 views
0

我想根据搜索框动态地过滤表格单元格内容。动态表格文本搜索

我有一个表有几个[3单元格]行。每个单元格都是独立的,每个单元格中都有一个用户名。

我想所有的细胞消失,除了符合搜索条件的一个或多个。

我已经在这里看了看,但没有运气(它使得整个行消失,而不是单个细胞):

http://www.marceble.com/2010/02/simple-jquery-table-row-filter/

任何帮助表示赞赏!由于

回答

0

如果你把网站上的代码,你所提到的:

//hide all the rows 
$("#fbody").find("tr").hide(); 
//split the current value of searchInput 
var data = this.value.split(" "); 
//create a jquery object of the rows 
var jo = $("#fbody").find("tr"); 

//hide all the rows 
$("#fbody").find("td").hide(); 
//split the current value of searchInput 
var data = this.value.split(" "); 
//create a jquery object of the rows 
var jo = $("#fbody").find("td"); 

这将隐藏的TD,而不是红素。但它可能会使格式化时髦,我会先测试它。

+0

感谢您的回答,这正是我3分钟前做的!问题是我需要一种方法来重新排序结果单元格(将它们向上移动到表格中,因为目前它们只是不移动,并且在结果表格中有孔) – 2012-02-20 20:54:47

+0

好吧,现在它工作..我刚刚多个复选框具有相同的值,当然会导致错误!谢谢! – 2012-02-25 19:28:55