就是html里面定义了<div id="content_r">和<table id="sortTable" class="listTable">和<th>表头然后在脚本那儿写的是$("#content_r table").append(若干<tr>和<td>);
这些<tr> <td> 与html里面的<th>表头相符合然后后台得到数据,然后反复循环的地一条条把记录append到<th>表下面我现在得到上头的需求是:在每条记录列出来中间,要插入一行完整的(很长没有间断)行,用于显示特殊信息
可是,它循环把记录append到<th>表里面后,我试着把我想要的哪一行append到<th>表里,由于只append了一个<td>,因此会与<th>的格式对不上发生前台错误 请问我这个需求肿么解决呢 谢谢了

解决方案 »

  1.   

    没有td项的会自动赋值为空吧?<html>
    <body><table id="ta" border="1">
      <tr>
        <th>Month</th>
        <th>Savings</th>
      </tr>
    </table>
    <script>
      var  table=document.getElementById("ta");
      var td1=document.createElement("td");
      td1.innerHTML="td1";
      table.appendChild(td1);
    </script>
    </body>
    </html>
      

  2.   

    好吧 我承认说的很乱
    就是我现在已经用js和后台SSH实现了在前台列出数据库所有信息到一个列表中使用的方法是用jquery封装好的函数反复输出从后台发来的数据,
    但是伤透现在有要求 就是每行数据之间,必须还有一行以一个<td>单列的形式空着,用于显示其他信息而且空着的这行只有一列,后台传回的数据有很多个列
    请问该怎么处理呢
      

  3.   

    没错是没错,但是这样前台脚本会出现问题,说什么少了几列吧 虽然不影响最后的结果,可是脚本错误这样的问题会被头头给揪住不放
    如下:this.rows[i].cells[target.cellIndex] is undefined
    [在此错误处中断] this.rows[i].cells[target.cellIndex].style.background='#e5f1f4';
    rowView.js (第 9 行)
    this.rows[i].cells[target.cellIndex] is undefined
    [在此错误处中断] this.rows[i].cells[target.cellIndex].style.background='#fff';
    rowView.js (第 23 行)
    this.rows[i].cells[target.cellIndex] is undefined
    [在此错误处中断] this.rows[i].cells[target.cellIndex].style.background='#e5f1f4';