我对jquery不太了解,所以请帮助我知道我们是否可以使用'这个'用于选择多个选择器的关键字,或选择以下函数中选择器的任何替代选项:
$('.calsub').click(function(){
var cRow=0,cCol=0;
var arrA = new Array(arow);
var arrB = new Array(acol);
for(cRow=0;cRow<acol;cRow++)
{
arrA[cRow] = new Array(acol);
arrB[cRow] = new Array(acol);
}
cRow=cCol=0;.matboxB .ipbox
$('.matboxA .ipbox, .matboxB .ipbox').each(function(){
if(this.value){
arrA[cRow][cCol] = this.value;
cCol++;
if(cCol==acol){
cCol=0;
cRow++;
}
}
else{
$(this).css('box-shadow','0 0 1px 2px #ff574b');
}
if(cRow==arow){
return false;
}
});cRow=0;cCol=0;
});
<div class="matboxA" style="max-width: 270px;">
<input class="ipbox" id="a00" type="text">
<input class="ipbox" id="a01" type="text">
<input class="ipbox" id="a02" type="text">
</div>
<div class="matboxB" style="max-width: 270px;">
<input class="ipbox" id="b00" type="text">
<input class="ipbox" id="b01" type="text">
<input class="ipbox" id="b02" type="text">
</div>
通过使用上面的JS函数,我只能选择.matboxA .ipbox
内的元素。使用this
关键字。如何选择&#39; .matboxB .ipbox&#39;中的元素。请帮帮我。
答案 0 :(得分:1)
当选择一个元素并执行一个过程时,jQuery会应用this参数。要选择此范围内的元素,可以使用jQuery find()
方法。
$('.matboxA .ipbox, .matboxB .ipbox').each(function(){
var innerElement = $(this).find('selector');
};