日期:2014-05-16  浏览次数:20320 次

能用innerHTML在table里添加行?
如果点击一个按钮,在table里面添加一行怎么办?为设么我添加的内容,不显示在我想要的位置


------解决方案--------------------
添加行可以用
var NewRow = TableObj.insertRow(RowInsert);
RowInsert表示添加到的位置,为-1时表示添加到表最后一列
添加列可以用
var NewCol = Row.insertCell(CellInsert);
CellInsert意义同RowInsert
然后可以直接操作
NewCol的innerHTML

------解决方案--------------------
function insert_row(){
R=document.getElementById( "sb ").insertRow();
C=R.insertCell();
C.innerHTML= "tr> <td> <input width= '90 ' type= 'text ' size= '13 ' maxlength= '15 ' style= 'border:0px;text-align:center;color:#3300FF ' readonly> </td> </tr> ";}
sb为表格名称