小编Bri*_*tas的帖子

如何遍历表行并使用jQuery获取单元格值

我使用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>
Run Code Online (Sandbox Code Playgroud)

我曾经像这样迭代表:

 $("tr.item").each(function() {
            var quantity1 = $this.find("input.name").val();
        var quantity2 = $this.find("input.id").val();

            });
Run Code Online (Sandbox Code Playgroud)

通过使用我得到第一行单元格值以上查询只...帮助我与jQuery将通过该表的完整行迭代,并在获得该行的单元格值quantity1quantity2.

javascript ajax jquery html-table

14
推荐指数
4
解决办法
8万
查看次数

根据文本匹配查找段落的ID

当我通过文本"选择列表"或"删除列表"时,如何获取段落的ID.

"<p id="section_548540600_title" class="CollapseExpand CollapseExpand_active" title="Collapse / Expand"><a href="javascript:void(0);">Selection List</a></p>"

"<p id="section_362548963_title" class="CollapseExpand CollapseExpand_active" title="Collapse / Expand"><a href="javascript:void(0);">Deletion List</a></p>"
Run Code Online (Sandbox Code Playgroud)

jquery

0
推荐指数
1
解决办法
215
查看次数

标签 统计

jquery ×2

ajax ×1

html-table ×1

javascript ×1