-1
need to insert some TD
within the TR
using jquery.
I’m doing it like this, but it doesn’t work
$(document).ready(function() {
$("table tbody .titulo").after("<td class='none'></td><td class='none'></td><td class='none'></td>");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table id="simple-table" class="table table-bordered table-hover">
<thead>
<tr>
<th>Página/Recurso</th>
<th>Ver</th>
<th>Editar</th>
<th>Excluir</th>
</tr>
</thead>
<tbody>
<tr>
<td class="titulo" colspan="4"><b class="blue">Topico 1</b></td>
</tr>
<tr>
<td class="p1">Contato</td>
<td><input name="permisao[]" type="checkbox" value="Ver"></td>
<td><input name="permisao[]" type="checkbox" value="Editar"></td>
<td><input name="permisao[]" type="checkbox" value="Excluir"></td>
</tr>
<tr>
<td class="titulo" colspan="4"><b class="blue">Topico 2</b></td>
</tr>
<tr>
<td class="p1">Contato</td>
<td><input name="permisao[]" type="checkbox" value="Ver"></td>
<td><input name="permisao[]" type="checkbox" value="Editar"></td>
<td><input name="permisao[]" type="checkbox" value="Excluir"></td>
</tr>
</tbody>
</table>
It’s working normal. You don’t see anything because you’re adding empty TD’s.
– Sam
They need to be empty, I just need them there for the table formatting to be right.
– Tiago
Look at the "inspect elements" of the browser that you will see they are.
– Sam
They are not, see http://prntscr.com/o1hnzf
– Tiago
Cannot repeat id’s. By print, it would have to be
$("#titulo").after(...
where the idtitulo
be unique on the page.– Sam
Find out the problem, I had put the
$(document).ready(function() {
after thejQuery(function($) {
, should be at the beginning. But then discover something else, theappend
is adding, but after the table is loaded, it is possible to have it loaded together with the table?– Tiago