我制作了this jsFiddle用于搜索/筛选我从XML响应中获得的div
内容。但我已经完成了一个文本框。任何人都可以帮助我实施未来三年?在DIV内容中筛选
例如:
如果我打字pd001
它显示了前两排,如果我输入粘贴应该从目前可见的列表不是从整个名单达到和过滤。
请帮助我解决这个问题。
我制作了this jsFiddle用于搜索/筛选我从XML响应中获得的div
内容。但我已经完成了一个文本框。任何人都可以帮助我实施未来三年?在DIV内容中筛选
例如:
如果我打字pd001
它显示了前两排,如果我输入粘贴应该从目前可见的列表不是从整个名单达到和过滤。
请帮助我解决这个问题。
如果我没有错,那么你必须要做的是如果我根据pd001
搜索2行并将paste
放在下一个文本框中,那么它应该只筛选那些2行而不是整个网格。和所有其他文本框相同的功能。事实上,你需要依赖B/W文本框。
试试这个:
$(".productid").filter(function() {
$(this).parent().hide();
return $(this).text().toLowerCase().indexOf(text0) != -1
}).parent().show();
$(".product:visible").filter(function() {
$(this).parent().hide();
return $(this).text().toLowerCase().indexOf(text1) != -1;
}).parent().show();
$(".quantity:visible").filter(function() {
$(this).parent().hide();
return $(this).text().toLowerCase().indexOf(text2) != -1;
}).parent().show();
$(".amount:visible").filter(function() {
$(this).parent().hide();
return $(this).text().toLowerCase().indexOf(text3) != -1;
}).parent().show();
你过滤只有一列,它可以帮助你
$("#searchone , #searchtwo ,#searchthree ,#searchfour").bind("keyup", function() {
var map = {
'.productid': $("#searchone").val().toLowerCase(),
'.product': $("#searchtwo").val().toLowerCase(),
'.quantity': $("#searchthree").val().toLowerCase(),
'.amount': $("#searchfour").val().toLowerCase()
};
$('div.new').each(function() {
$(this).hide();
});
$('div.new').each(function() {
var parent_div = this;
$.each(map, function(key, value) {
$(parent_div).find(key).filter(function() {
if ($(this).text().toLowerCase().indexOf(value.toString()) != -1 && value != '') {
$(parent_div).show();
}
});
});
});
});
嗨,谢谢你的努力,但是你的代码并没有提供给我o/p我正在寻找的东西...... filiter并没有像通缉那样工作。 ANY hw感谢你的努力Ronak :) – Harry 2012-08-16 16:26:17
那想我需要和真的谢谢你这么多修复。伟大的人:) – Harry 2012-08-16 11:29:41
@哈里:很高兴它为你工作。我也会喜欢上一个:-) – codef0rmer 2012-08-16 11:50:53