开发者

rookie shopping cart won't add new items only replace 1st item when clicking add button

instead of adding a new table row, the table row gets replaced

 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;

(note I cannot 开发者_Go百科use jQuery or any other library for this assignment)


You have to append the new row instead of replacing it. The question basically answers itself:

//In the beginning
var allRows = '';

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

You might want to check some DOM manipularion methods as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜