[英]using jquery find on result set of find
When I do a find look-up on my table for hidden fields, I am seeing my two hidden fields. 当我在表上查找隐藏字段时,我看到了两个隐藏字段。 However, I want to further refine these 2 fields by their IDs.
但是,我想通过它们的ID进一步完善这两个字段。 I notice that when I use find on the entire table using the "contains" that I get my 2 fields.
我注意到,当我使用“包含”在整个表上使用find时,得到了2个字段。 However, if I do a find on the find results from the hidden fields, it returns an empty set.
但是,如果我对隐藏字段的查找结果进行查找,它将返回一个空集。 Can anyone explain why this is the case?
谁能解释为什么会这样?
var table = sender.parentNode.parentNode.parentNode.parentNode;
// this finds my 2 hidden fields
var hidden_fields = $(table).find("input[type='hidden']");
// this finds each of the 2 fields individually by ID
var my_id_fieldA = $(table).find("[id*='hfMyIdFieldA']");
var my_id_fieldB = $(table).find("[id*='hfMyIdFieldB']");
// but this returns an empty set
var my_id_fieldA = $(hidden_fields).find("[id*='hfMyIdFieldA']");
You're looking for the filter
function, not find
. 您在寻找
filter
功能,而不是find
。 find
selects child elements while filter
filters the current selection. find
选择子元素,而filter
过滤当前选择。
Also there's no reason to find the table like that... try something like this. 同样也没有理由找到这样的表...尝试这样的事情。
var $table = $(sender).closest("table")
, $hidden_fields = $table.find("input[type='hidden']")
, $my_id_fieldA = $hidden_fields.filter("[id*='hfMyIdFieldA']")
, $my_id_fieldB = $hidden_fields.filter("[id*='hfMyIdFieldB']")
, $my_id_fieldA = $hidden_fields.filter("[id*='hfMyIdFieldA']")
;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.