3
Hello I would like to generate a dynamic table in java script(only the tr and td) for this I am using innerHTML.
I make the following code:
objDiv1 = document.getElementById("tabela");
bloco += "<tr><td>"+ Campo+"</td></tr>";
objDiv1.innerHTML = bloco;
You are generating the right html but you are playing above my table.
If I take and give a console.log and paste in the place where it is this div will work:
My html structure is like this:
<table class="table">
<thead class=" text-primary">
<th>
Lote
</th>
</thead>
<tbody>
<div id="tabela">
</div>
</tbody>
</table>
What am I doing wrong?
I believe the most wrong thing is to put a
div
inside a table, this is really necessary?– Costamilam
@Guilhermecostamilam what would be the other way for me to pass an id and add the tr and td?
– Ribak
Adds direct to tbody or table itself
– edson alves
You should not use div inside table, and if you are going to use change its display to display:table-Cell, it may work although it is not the right one...
– hugocsl
You can switch from innerHTML to outerHTML, it should work
– edson alves