-2

我有测验结果表格,表格中有一个成绩单元格。

示例(单元格等级在 while 循环中,并且在使用 if 检查其他单元格后出现数字):

    <table border="1">
      <tbody>
        <tr>
          <th> id </th>
          <th> question </th>
          <th> answer </th>
          <th> correct answer </th>
          <th> grade </th>


        </tr>

        <tr>

          <td> 1 </td>
          <td> question how bla bla bla</td>
          <td> bla bla answer</td>
          <td> correct answer</td>
          <td> 5 (this cell has the grade of each question)</td>
        </tr>
        <tr>

          <td> 2 </td>
          <td> question2 how bla bla bla</td>
          <td> bla bla answer2</td>
          <td> correct answer2</td>
          <td> 8 (this cell has the grade of each question)</td>
        </tr>

ETC

// in this cell i want to show me the average from td grade

<td colspan="4" align="center">average</td>
  <td><input type="text" readonly="readonly" name="Avg" /></td>      


      </tbody>
    </table>

多谢!!

4

1 回答 1

1

看到这个 tut http://www.amitpatil.me/table-manipulation-with-jquery/您可能正在寻找的内容在上面页面的第 5 点中提到,即“5)从特定列的 td 中查找所有值”

$(".grid tr").each(function(i){
   colValues[i] = $('tr:nth-child('+(i+1)+')>td:nth-child(1)').html();
});
于 2013-01-02T09:05:02.760 回答