I don't know much about jquery, So help me to know whether we can use 'this' keyword to select multiple selectors or any alternative to select selectors inside a function like below:
$('.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>
By Using JS function above I can only select elements inside .matboxA .ipbox. by using this keyword. How can I select elements inside '.matboxB .ipbox'. Please help me.
When an element is selected and a procedure follows, jQuery applies the this parameter. To select elements within this scope, one can use the jQuery find() method.
$('.matboxA .ipbox, .matboxB .ipbox').each(function(){
var innerElement = $(this).find('selector');
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With