gpt4 book ai didi

javascript - 在 DIV 内容中过滤

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:35:35 27 4
gpt4 key购买 nike

我做了this jsFiddle用于搜索/过滤我从 XML 响应中获取的 div 内容。但是我已经为一个文本框单独完成了。任何人都可以帮助我实现接下来的三个?

例如:

如果我输入 pd001,它会显示前两行,如果我输入 paste,它应该到达并从当前可见列表中过滤,而不是从整个列表中过滤。

请帮我解决这个问题。

最佳答案

如果我没记错,那么您一定是想做的是,如果我根据 pd001 搜索 2 行并将 paste 放在下一个文本框中,那么它应该只过滤那两行而不是整个网格。以及所有其他文本框的相同功能。事实上,您需要依赖黑白文本框。

试试这个:

    $(".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/

关于javascript - 在 DIV 内容中过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11984288/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com