6
I cannot assign a value to my td within a table, it contains id
dynamic as in the example below:
<table class="table table-condensed table-hover" id="tabelaDependentes">
<caption>Lista de Dependentes</caption>
<thead>
<tr>
<th>CPF</th>
<th>Tipo Dependente</th>
</tr>
</thead>
<tbody>
<tr style="cursor: pointer" data-depedente-id="30">
<td id="depedente-cpf-30">2323</td>
<td id="depedente-tipo-30">teste</td>
</tr>
<tr style="cursor: pointer" data-depedente-id="31">
<td id="depedente-cpf-31">09298618417</td>
<td id="depedente-tipo-31">teste</td>
</tr>
<tr style="cursor: pointer" data-depedente-id="32">
<td id="depedente-cpf-32">jose2</td>
<td id="depedente-tipo-32">teste</td>
</tr>
<tr style="cursor: pointer" data-depedente-id="33">
<td id="depedente-cpf-33">123</td>
<td id="depedente-tipo-33">teste</td>
</tr>
</tbody>
</table>
But the JS code doesn’t work:
$("#depedente-cpf-31").html('teste');
the problem he doesn’t even find this id , gives Undefined
– Jose Vieira Neto
I did a test with your HTML and it worked. I edited the answer now.
– Pedro Camara Junior
The way you are doing should work as well. You added jQuery’s reference?
– Pedro Camara Junior