Loop step by step to create the html table - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:TableData

Description

Loop step by step to create the html table

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(){/*from   ww  w.j  a va2 s .c  om*/
var tbl = document.createElement("table");
for(var i=0;i<=10;i++){
    var tr = document.createElement("tr");
    for(var j=0;j<=10;j++){
        var td = document.createElement("td");
        td.innerHTML = i*j;
        tr.appendChild(td);
    }
    tbl.appendChild(tr);
}
document.body.appendChild(tbl);
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials