通过jQuery查找深层嵌套的输入 [英] Find deeply nested input by jquery
问题描述
< div id =customerServices>
< div id =pnlCustomerServices_Container>
<! - 以及其他许多div ...... - >
< div id =s1_Container>
< div id =ext-gen32>
<! - - 和其他许多divs ........ - >
< input type =checkboxid =s1
name =s1class =x-form-checkbox and_many_classes ..... parentvalue =s1>
< label for =s1class =x-form-cb-label font-bold
id =ext-gen33> Label1Text< / label>
<! - - 和其他许多divs ........ --->
< / div>
< / div>
< div id =s2_Container>
< div id =ext-gen33>
<! - - 和其他许多divs ........ - >
< input type =checkboxid =s2
name =s2class =x-form-checkbox and_many_classes ..... parentvalue =s2>
< label for =s2class =x-form-cb-label font-bold
id =ext-gen34> Label1Text< / label>
<! - - 和其他许多divs ........ --->
< / div>
< / div>
< / div>
< / div>
我想查找所有输入checkBox
(在这种情况下输入checkBox id =s1
和输入checkBox id =s2
)包含parent并嵌套在 div id =customerServices
中。
但是难以确定的是 customerServices
和 input class = parent
以及有多少个值具有输入的属性类。
更新:前段时间
我正在使用下面的代码。但它不适用于当前的任务。
$('#customerServices input:checkbox [class =parent] );
update2:
还有一件事。我怎样才能找到没有属性的复选框 class = parent
$('#customerServices input:checkbox [class ^ =parent]')
有什么问题:
$('。parent')
code>
或
$( 'input .parent')
要更新:
$('#customerServices input:checkbox [class =parent]');
选择复选框,其中 class
等于parent 。但是你的类属性包含更多。您需要:
$('#customerServices input:checkbox.parent');
更新2:
$('#customerServices input:checkbox:not(.parent)');
<div id="customerServices">
<div id="pnlCustomerServices_Container">
<!-- and many others divs...... -->
<div id="s1_Container">
<div id="ext-gen32">
<!-- and many others divs........ -->
<input type="checkbox" id="s1"
name="s1" class=" x-form-checkbox and_many_classes..... parent" value="s1">
<label for="s1" class="x-form-cb-label font-bold"
id="ext-gen33">Label1Text</label>
<!-- and many others divs........ --->
</div>
</div>
<div id="s2_Container">
<div id="ext-gen33">
<!-- and many others divs........ -->
<input type="checkbox" id="s2"
name="s2" class=" x-form-checkbox and_many_classes..... parent" value="s2">
<label for="s2" class="x-form-cb-label font-bold"
id="ext-gen34">Label1Text</label>
<!-- and many others divs........ --->
</div>
</div>
</div>
</div>
I want to find all input checkBox
(in this case input checkBox id="s1"
and input checkBox id="s2"
) that have the attribute class contains "parent" and nested inside div id="customerServices"
.
But the difficult is it's unknown how many divs are between customerServices
and input class = "parent"
and how many values has input's attribute class.
update: some time ago I was using the following code. But it doen't work for the current task.
$('#customerServices input:checkbox[class="parent"]');
update2:
And one more thing. How can I find the checkBox which doesn't have attribute class=parent
$('#customerServices input:checkbox[class^="parent"]')
What's wrong with:
$('.parent')
or
$('input .parent')
To your update:
$('#customerServices input:checkbox[class="parent"]');
selects the checkbox where class
equals "parent". But your class attribute contains much more. You need:
$('#customerServices input:checkbox.parent');
update 2:
$('#customerServices input:checkbox:not(.parent)');
这篇关于通过jQuery查找深层嵌套的输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!