动态添加、删除表格行

function addRow(tableid){
         var tb1=document.getElementById(tableid); 
         var newRow=tb1.insertRow(tb1.rows.length-1);
        
         $("#"+tableid+" tr:last").find("td").each(function (i){
         newRow.insertCell(i).innerHTML=$(this).html();
   
         });
          if(!$("#"+tableid+" tr:last").find("td:last").children().is("img")){
            $("#"+tableid+" tr:last").find("td:last").append("<img width='15' style='margin-top:-15px;float:right;' height='15' onclick='deleteRow(this.parentNode);' src='"+siteStyle+"/images/del.gif'/>")
         
          }
         trCssFun2();
}
function deleteRow(t){
 t.parentNode.parentNode.deleteRow(t.parentNode.rowIndex);
}

你可能感兴趣的:(html)