Javascript jQuery-如果任何单元格包含X和Y之间的值,则删除表行

Javascript jQuery-如果任何单元格包含X和Y之间的值,则删除表行,javascript,jquery,Javascript,Jquery,我正在尝试显示/隐藏基于邮政编码的商店列表。 数据是通过php加载到WP站点上的,我正在尝试创建一个脚本,通过该脚本,我可以根据用户选择的区域隐藏/显示商店。 为此,我需要展示邮政编码介于8000和9000之间的商店, 而其他所有的商店都隐藏起来了 我试过了,但是没有用 $("#prices td").each(function() { if ($(this).val() >= 8000 && $(this).val() <= 9000){

我正在尝试显示/隐藏基于邮政编码的商店列表。 数据是通过php加载到WP站点上的,我正在尝试创建一个脚本,通过该脚本,我可以根据用户选择的区域隐藏/显示商店。 为此,我需要展示邮政编码介于8000和9000之间的商店, 而其他所有的商店都隐藏起来了

我试过了,但是没有用

$("#prices td").each(function() { 
    if ($(this).val() >= 8000 && $(this).val() <= 9000){
        $(this).parent().hide();
};
$(“#prices td”).each(function(){

如果($(this.val()>=8000&&$(this.val()这对我来说似乎很合适:

HTML:


JQuery:

$("input[id^=prices]").each(function() { 
    if ($(this).val() >= 8000 && $(this).val() <= 9000){
        $(this).parent().hide();
    }
});
$(“输入[id^=prices]”)。每个(函数(){

如果($(this.val()>=8000&&$(this.val())=8000&&parseInt($(this.text())=8000&&$(this.text()),我希望查看表的HTML。但是查看您的代码,我会告诉您使用
$(this).查找('zip列').text()
和`$(this).closest().hide()编辑它以包含一些标记。我发现.val属性可能是错误的,因为邮政编码只是中的文本,而不是输入字段的值。@DanielPaaske是的,使用文本,没有val()属性。$($td[id^=prices])。每个(函数(){if($(this).text()>=8000&$(this).text()谢谢。但它仍然不起作用。我的目标是错误的吗?#prices id是td上方的div 8级别,但td下方的所有级别都有通用类。您可以在此处查看:如果您的类是price,则需要使用类选择器:$(“.price”)请参阅更新的小提琴:“prices”是一个div的ID,里面有一个div,另一个div,另一个div,antoher div,一个表,一个tbody,一个tr,然后是td。我会明确地遍历整个路径吗?或者像#prices td那样做可以吗?
<table>
    <tr>
        <td><input id="prices0" /></td>
    </tr>
    <tr>
        <td><input id="prices1" /></td>
    </tr>
    <tr>
        <td><input id="prices2" value="8001"/></td>
    </tr>
    <tr>
        <td><input id="prices3" /></td>
    </tr>
</table>
$("input[id^=prices]").each(function() { 
    if ($(this).val() >= 8000 && $(this).val() <= 9000){
        $(this).parent().hide();
    }
});
$("td[id^=prices]").each(function() { 
    if (parseInt($(this).text()) >= 8000 && parseInt($(this).text())<= 9000) {
        $(this).parent().hide();
    }
});
$("td[id^=prices]").each(function() { 
    if ($(this).text() >= 8000 && $(this).text() <= 9000){
        $(this).parent().hide();
        }
});