我正在使用 jQuery 动态创建下表…执行我的代码后,我得到如下表:
<table id="TableView" width="800" style="margin-left: 60px">
<tbody>
<tr>
<th>Module</th>
<th>Message</th>
</tr>
<tr class="item">
<td> car</td>
<td>
<input class="name" type="text">
</td>
<td>
<input class="id" type="hidden" value="5">
</td>
</tr>
<tr class="item">
<td> bus</td>
<td>
<input class="name" type="text">
</td>
<td>
<input class="id" type="hidden" value="9">
</td>
</tr>
我曾经像这样迭代表:
$("tr.item").each(function() {
var quantity1 = $this.find("input.name").val();
var quantity2 = $this.find("input.id").val();
});
通过使用上面的查询,我只得到第一行单元格的值…帮助我使用 jQuery,它将遍历表的整行并获取 quantity1
和 quantity2
中的行单元格值 ---
。
原文由 Brittas 发布,翻译遵循 CC BY-SA 4.0 许可协议
$(this)
而不是 $this证明_1
证明_2