问题描述
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查找深层嵌套的输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!