How to create a Html table using DOM model using Javascript?
for ex:
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="tblMCNRoles">
</table>
I have above table and i want to render above table like below by using DOM modal creation.
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="tblMCNRoles">
<tr>
<td bordercolor="green" align="center" valign="top" style="border-style:dotted" >
<table width="99%" border="0" cellspacing="0" cellpadding="0"
class="portlet-table-body intable5">
<tr><td align="center" valign="middle" class="grid6"></td></tr>
</table>
</td>
</tr>
</table>
I suggest you use the DOM Table methods since neither appendChild nor innerHTML are good for safe cross browser manipulation.
The DOM has insertRow and insertCell which works better.
Here is IE’s documentation and here is an example from Mozillas Developer Network