一 js操作table

来源:互联网 发布:网络在线客服是什么 编辑:程序博客网 时间:2024/05/22 06:06
 
function   AddAttachments()
{

document.getElementById( 'attach ').innerText   =   "继续添加附件 ";
tb   =   document.getElementById( 'attAchments ');
newRow   =   tb.insertRow();
newRow.insertCell().innerHTML   =   " <input   class= 'ButtonCss '   name= 'File '   size= '50 '   type= 'file '> &nbsp;&nbsp; <input   class= 'ButtonCss '   type=button   value= '删除 '   onclick= 'delFile(this.parentElement.parentElement.rowIndex) '> ";
}
function   delFile(index)
{
document.getElementById( 'attAchments ').deleteRow(index);
tb.rows.length   >   0?document.getElementById( 'attach ').innerText   =   "继续添加附件 ":document.getElementById( 'attach ').innerText   =   "继续添加附件 ";
}
function   addFile()  
        {  
              var   str   =   ' <INPUT   type= "file "   size= "50 "   Name= "File "> '  
              document.getElementById( 'MyFile ').insertAdjacentHTML( "beforeEnd ",str)  
        }
function   delFile()  
        {  
var   objArr=document.getElementById( 'MyFile ').getElementsByTagName( "input ");
objArr[objArr.length-1].removeNode(true);
        }