I am generating a report and it has several tables. In jQuery I have to add 2 inputs of each table, the problem is that it only adds the one of the first table. I tried to use next()
, but it did not work.
Follow the HTML code:
<td id=\"tabela\">
<input type=\"text\" id=\"tabelainput\" class=\"janmembros\" maxlength=\"3\" name=\"janmembros\" value=\"$row[janmembros]\" disabled>
</td>
<td id=\"tabela\">
<input type=\"text\" id=\"tabelainput\" class=\"janvisitantes\" maxlength=\"3\" name=\"janvisitantes\" value=\"$row[janvisitantes]\" disabled>
</td>
<td id=\"tabela3\" class=\"jantotal\">
</td>
<td id=\"tabela\">
<input type=\"text\" id=\"tabelainput\" class=\"janmembros\" maxlength=\"3\" name=\"janmembros\" value=\"$row[janmembros]\" disabled>
</td>
<td id=\"tabela\">
<input type=\"text\" id=\"tabelainput\" class=\"janvisitantes\" maxlength=\"3\" name=\"janvisitantes\" value=\"$row[janvisitantes]\" disabled>
</td>
<td id=\"tabela3\" class=\"jantotal\">
</td>
<td id=\"tabela\">
<input type=\"text\" id=\"tabelainput\" class=\"janmembros\" maxlength=\"3\" name=\"janmembros\" value=\"$row[janmembros]\" disabled>
</td>
<td id=\"tabela\">
<input type=\"text\" id=\"tabelainput\" class=\"janvisitantes\" maxlength=\"3\" name=\"janvisitantes\" value=\"$row[janvisitantes]\" disabled>
</td>
<td id=\"tabela3\" class=\"jantotal\">
</td>
jQuery:
if ( $( ".janmembros" ).val().length >= 1 && $( ".janvisitantes" ).val().length >= 1 )
{
$( ".jantotal" ).html( parseInt($( ".janmembros" ).val()) + parseInt($( ".janvisitantes" ).val()) );
}