筛选 DIV 内容
Filter in DIV content
我已经制作了这个jsFiddle,用于搜索/过滤我从XML响应中获得的div
内容。但是我只为一个文本框做了。有人可以帮助我实施接下来的三个吗?
例如:
如果我输入pd001
它会显示前 2 行,如果我键入粘贴,它应该到达并从当前可见列表而不是整个列表中过滤。
请帮帮我解决这个问题。
如果我
没有错,那么你必须尝试做的是 如果我根据pd001
搜索 2 行并paste
放在下一个文本框中,那么它应该只过滤这 2 行而不是整个网格。所有其他文本框的功能相同。实际上,您需要依赖项黑白文本框。
试试这个:
$(".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();
演示:http://jsfiddle.net/fbC6w/4/
您只过滤了一列,它可能会对您有所帮助
$("#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();
}
});
});
});
});
相关文章:
- 如何将DIV标记的内容拆分为多个DIV
- 如何使 DIV 中的内容垂直对齐
- 将Div内容复制到文本区域或具有相同字体族样式的文本
- jQuery在5秒钟后隐藏/删除DIV内容
- 基于地理IP更改Div内容
- 内容可编辑DIV单击/插入符号设置
- 如何使用Javascript替换和隐藏Div内容
- jQuery获取子DIV的HTML内容
- 用Div内容创建obj
- 使用CSS打印DIV内容,不起作用
- 筛选 DIV 内容
- 内容可编辑 DIV 中的大量替换
- 是否可以使用 DIV 而不是 iFrame,以便内容看起来像在同一页面中
- 我想使用hashbang URL(blah.com/#!/thingtoload)动态加载页面内容(在DIV中),我有j
- WebGL Three.js在画布Div可见之前,不会加载某些内容
- 如何使用JavaScript添加动态HTML内容(DIV)
- 如何动态查找HTML文档的主要内容DIV
- 隐藏内容DIV并在按下搜索按钮后显示它
- 禁用& lt; img>在ie9中选择和调整可内容DIV的大小
- 动态生成内容DIV