实现代码:<table class="table-detail"><tr> <th>名称</th> <th>总计</th></tr></table><script type="text/javascript">var baseData = [ {"name":"昌大","total":"1000"}, {"name":"西江红","total":"2000"}];window.onload = function() { var mytable = document.getElementsByTagName('table')[0]; for(var i = 0; i < baseData.length; i++) { var tr = mytable.insertRow(mytable.rows.length); var obj = baseData[i]; for(var p in obj) { var td = tr.insertCell(tr.cells.length); td.innerText = obj[p]; } }}</script>但是,我想要增加一列,自动生成序号,如下图。
添加回答
举报
0/150
提交
取消