Rumah > hujung hadapan web > tutorial js > javascript mencipta kemahiran tables_javascript secara dinamik

javascript mencipta kemahiran tables_javascript secara dinamik

WBOY
Lepaskan: 2016-05-16 16:21:33
asal
961 orang telah melayarinya

Salin kod Kod adalah seperti berikut:


                                                                                                                                                                                                                                           fungsi createTable(baris, garisan){
This.rows=rows;
This.lines=lines;
                  var Body=document.getElementById('body');
                      var Table=document.createElement('table');//Buat elemen teg jadual
                    Table.setAttribute('sempadan','1');
//Tambahkan atribut lain pada teg jadual
for(var i=0;i                              var lRow=document.createElement('tr');
for(var j=0;j                                                                     var textNode=document.createTextNode(i ',' j);
... lLine.appendChild(textNode);
lRow.appendChild(lLine);
                                                                                                                                                                            Table.appendChild(lRow);
                 }
                       Body.appendChild(Jadual);
                }
                                                                                                                                                                                                                                                                                                                                                                                               

                                                                                                        
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan