2011-02-15 42 views
0

,而不是添加一个新的表行替换第一个项目,表行被替换新秀购物车将不会增加新的项目只有当点击添加按钮

itemRow = "<tr><td class='txt'>" + somevalue + "</td><td>" + somevalue + "</td><td>" + somevalue + "</td><td class='nr'>" + somevalue + "</td></tr>" 

table = "<table>" + itemRow +"</table>"       

div.innerHTML = table; 

(请注意,我不能使用jQuery或任何其他库对于此作业)

回答

1

您必须追加新行而不是替换它。这个问题基本上回答自己:

//In the beginning 
var allRows = ''; 

//To add a new row 
allRows += "the new row"; 
table = "<table>" + allRows + "<table>" 

你可能要检查一些DOM manipularion methods为好。

+0

好的!它的工作非常感谢! – Immers 2011-02-16 09:42:19

相关问题