我如何在父级引用变量的父级中选择具有特定类名的每个元素。
例如:
$('.tenUnit').each(function(index, element){
//below element is a parent that is a variable
$('element .specifyClass').each(function(index2, element2){
// ... some code ...
});
});
<div class="tenUnit"><!-- parent 1 -->
<div>
<input class="specifyClass"> <!-- can be anywhere inside div.tenUnit -->
</div>
<input class="specifyClass"><!-- can be anywhere inside div.tenUnit -->
</div>
<div class="tenUnit"><!-- parent 2 -->
<div>
<input class="specifyClass"> <!-- can be anywhere inside div.tenUnit -->
</div>
<input class="specifyClass"><!-- can be anywhere inside div.tenUnit -->
</div>