js写table表

     var _table = document.getElementById("mytable2");
                    for(var i=1;i<10;i++){
                        var row=document.createElement ("tr");
                        row.id=i;
                        for(var j=1;j<6;j++){
                            var cell=document.createElement ("td");
                            cell.id =i+"/"+j;
                            cell.appendChild(document.createTextNode (""+cell.id+""));
                            row.appendChild (cell);
                        }
                        _table.appendChild (row);
                    }

猜你喜欢

转载自www.cnblogs.com/ynhk/p/12029891.html