Heim >Web-Frontend >js-Tutorial >Javascript erstellt dynamisch Tabellen_Javascript-Fähigkeiten

Javascript erstellt dynamisch Tabellen_Javascript-Fähigkeiten

WBOY
WBOYOriginal
2016-05-16 16:21:33968Durchsuche

Code kopieren Der Code lautet wie folgt:


                                                                                                                                                                                                                Funktion createTable(rows,lines){
This.rows=rows;
This.lines=lines;
                  var Body=document.getElementById('body');
                      var Table=document.createElement('table');//Tabellen-Tag-Element erstellen
                    Table.setAttribute('border','1');
//Weitere Attribute zum Tabellen-Tag hinzufügen
for(var i=0;i                             var lRow=document.createElement('tr');
for(var j=0;j                                                           var textNode=document.createTextNode(i ',' j);
                                                                                             var lLine=document.createElement('td');
lLine.appendChild(textNode);
lRow.appendChild(lLine);
                                                                                                       }                        Table.appendChild(lRow);
                 }
                      Body.appendChild(Table);
                }