<html>
<head>
<title>Browser Detection</title>
<script language="Javascript">
function del(o)
{
while(o.tagName!="TR")
o = o.parentElement
document.all.x.deleteRow(o.rowIndex)
}
function add(o)
{
while(o.tagName!="TR")
o = o.parentElement
oTr=document.all.x.insertRow(o.rowIndex)
oTd  = oTr.insertCell(0)
oTd .innerHTML=Date.parse(new Date())
oTd  = oTr.insertCell(1)
oTd .innerHTML='<input type="button" onclick="del(this)" value=delete>'
oTd  = oTr.insertCell(2)
oTd .innerHTML='<input type="button" onclick="add(this)" value=Add>'
}
</script>
</head>
<body>
<table id=x border>
<tr>
<td>xxxx</td>
<td><input type="button" onclick="del(this)" value=delete></td>
<td><input type="button" onclick="add(this)" value=Add></td>
</tr>
<tr>
<td>xxxx</td>
<td><input type="button" onclick="del(this)" value=delete></td>
<td><input type="button" onclick="add(this)" value=Add></td>
</tr>
</table>
</body>
</html>

解决方案 »

  1.   

    http://lucky.myrice.com/javascriptexam/addelement.htm
      

  2.   

    //插入一行/删除你可以自己学会改一个FUN出来就可以了。(包含录入表单下的做法,如果只是一个表做的话就不用了,那个相对是很简单的,本身TABLE就可在JAVASCRIPT中随意操作的。)
    function cp_insert(obj)
    {   var i;
        tmp = document.all.eare_cp_select.innerHTML;
    tmp1 = tmp.split("<TBODY>");
    tmp = tmp1[0];
    tmp += document.all.tab_cp_select.childNodes[0].children[0].outerHTML;
    tmp += document.all.tab_cp_select.childNodes[0].children[1].outerHTML;
    for (i=2;i<document.all.tab_cp_select.childNodes[0].children.length;i++)
    {
     if (document.all.tab_cp_select.childNodes[0].children[i] == obj)
        tmp += document.all.tmp_cp_select.childNodes[0].children[0].outerHTML;
                tmp += document.all.tab_cp_select.childNodes[0].children[i].outerHTML;
    }
    tmp += "</TABLE>";
    document.all.eare_cp_select.innerHTML = tmp;
    }
      

  3.   

    http://expert.csdn.net/Expert/topic/2756/2756260.xml?temp=.9067194