以下程序是动态添加删除table行的javascript,IE6 上测试通过:

 1 <! DOCTYPE HTML PUBLIC  " -//W3C//DTD HTML 4.0 Transitional//EN " >
 2 < HTML >
 3 < HEAD >
 4 < TITLE >  动态添加元素  </ TITLE >
 5 < META NAME = " Generator "  CONTENT = " EditPlus " >
 6 < META NAME = " Author "  CONTENT = "" >
 7 < META NAME = " Keywords "  CONTENT = "" >
 8 < META NAME = " Description "  CONTENT = "" >
 9 </ HEAD >
10 < SCRIPT LANGUAGE = " JavaScript " >
11 <!--
12 var  n  =   1 ;
13 function  testAdd()
14 {
15      var  tr  =  document.getElementById( " xxxx " ).insertRow( 1 );
16     tr.id = " new_ " + n;
17      var  c1  =  tr.insertCell();
18     c1.innerText = " xxx " + n;
19      var  c2  =  tr.insertCell();
20     c2.innerText = " bbb " ;
21
22      var  c3  =  tr.insertCell();
23     c3.innerHTML = " <a href='#' onclick=doDelete('new_ " + n + " ')>del</a> " ;
24     n ++ ;    
25 }

26 function  doDelete(i)
27 {
28    var  tr  =  document.getElementById(i);
29
30   document.getElementById( " xxxx " ).deleteRow(tr.rowIndex);
31 }

32 // -->
33 </ SCRIPT >
34 < BODY >
35 < input type = " button "  value = " + "  onclick = " testAdd() " >
36 < table name = " tt "  border = " 1 "  id = " xxxx " >
37 < tr id = " xxx " >
38    < td > name22222 </ td >
39    < td > value </ td >
40    < td >& nbsp; </ td >
41 </ tr >
42 </ table >
43 </ BODY >
44 </ HTML >
45