当前位置: 代码迷 >> Web前端 >> 动态地增添或或删除table里的行
  详细解决方案

动态地增添或或删除table里的行

热度:8   发布时间:2012-09-06 10:37:01.0
动态地添加或或删除table里的行
<div id="fileDiv">
<table id="picTable"></table>
&nbsp;&nbsp;
<a href="javascript:void(addPicFile('picTable'));"
class="file">添加图片</a>
*
</div>

<script type="text/javascript">
function addPicFile(idstr) {
currRow=document.getElementById(idstr).insertRow();
cellc=currRow.insertCell();
if(idstr=='picTable')
{
cellcContext= "<input type='file'id ='tt' NAME='file'>&nbsp;&nbsp;<button onclick=\"removePicFile(\'picTable\',this.parentNode.parentNode.rowIndex);\">删除</button><br>";
}
cellc.innerHTML=cellcContext;
}

function removePicFile(idstr,rowIndex){
document.getElementById(idstr).deleteRow(rowIndex);
}
</script>
  相关解决方案