Given table:
<table class="matrixA" align="center"> <tr> <td><input type="text" placeholder="a1,1"></td> <td><input type="text" placeholder="a1,2"></td> </tr> <tr> <td><input type="text" placeholder="a2,1"></td> <td><input type="text" placeholder="a2,2"></td> </tr> </table>
It is necessary to make a check on the values entered into the inputs: it should not be more than 10. I have done this:
$(".matrixA input:text").each(function () { if ($(this).val() > 10) { $('.left-block').css('backgroundColor', '#f6c1c0'); $('#error2').show(); $('#multiple').addClass('disabled'); } else { $('.left-block').css('backgroundColor', '#bcbcbc'); $('#error2').hide(); $('#multiple').removeClass('disabled'); }; });
But for some reason it only checks the last cell in the table (which is a2,2)