[英]how to select parent based on value of its child?
i Want to select all parent element based on the value of child input value in j query 我想基于j查询中子输入值的值选择所有父元素
which i can do that from this command 我可以从这个命令做到这一点
$(".XXXX tr").has("input.YYYYYY[value = 36816323]")
and it works fine but now i want to select all parent whose child input have value greater than 36816323 so i modify according to it 它工作正常,但现在我想选择所有子项输入值大于36816323的父项,因此我根据它进行了修改
$(".XXXX tr").has("input.YYYYYY[value >= 36816323]")
but now its giving error unrecognized expression 但是现在它的给出错误无法识别的表达
any help will be appreciated 任何帮助将不胜感激
You can use, 您可以使用,
$(".XXXX tr").has("input.YYYYYY").filter(function() {
return parseInt($(this).val()) > 36816323;
}).closest("tr");
Use .filter()
method: 使用
.filter()
方法:
$(".XXXX tr").filter(function(){
return +$(this).find('input').val() > 36816323;
}).css('background', 'yellow');
Here .filter()
lets you filter the specific tr
elements which contains an input with value of more than 36816323
. 在这里
.filter()
可以过滤包含输入值大于36816323
的特定tr
元素。 But remember to parse the input value as number either with leading +
or parseInt(val, 10)
. 但是请记住使用前导
+
或parseInt(val, 10)
将输入值解析为数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.