Create table row and table data - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:TableData

Description

Create table row and table data

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//ww w  .  j  a  v  a2 s  . c o  m
tab = document.getElementById('tab');
for(i=0; i<3; i++)
{
 var tr = document.createElement("tr");
  for(j=0; j<3; j++)
  {
    var td = document.createElement("td");
    td.id = i+''+j;
    td.innerHTML= i+''+j
    tr.appendChild(td);
  }
 tab.appendChild(tr);
}
    }

      </script> 
   </head> 
   <body> 
      <table id="tab"></table>  
   </body>
</html>

Related Tutorials