Home > Web Front-end > JS Tutorial > body text

javascript dynamically create tables_javascript skills

WBOY
Release: 2016-05-16 16:21:33
Original
948 people have browsed it

Copy code The code is as follows:


                                                                                                                                                                                                                         function createTable(rows,lines){
This.rows=rows;
This.lines=lines;
                  var Body=document.getElementById('body');
                      var Table=document.createElement('table');//Create table tag element
                    Table.setAttribute('border','1');
//Add other attributes to the table tag
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);
                }
                                                                                                                                                                                                                                                                                                                                     

                                                                                                 
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!