gpt4 book ai didi

jquery - 如何使用JQuery获取html表格中的单元格值

转载 作者:行者123 更新时间:2023-12-03 22:44:08 24 4
gpt4 key购买 nike

我看到很多帖子谈论我的问题,但其中任何一个都对我有用。

我有这个 html 表,我想获取单元格“索引”下的值。我如何使用 jQuery 来实现这个:

<table id="htmlTable">
<caption>Informations des hotspots</caption>
<thead>
<tr>
<th>Index</th>
<th>Nom du hotspot</th>
<th>Image du hotspot</th>
</tr>
</thead>
<tbody>
<tr id="0">
<td>0</td>
<td>Hotspot Fribourg Centre</td>
<td>../images/logos_hotspot/logo_wifi_centre.png</td>
<td>
<input type="button" value="supprimer" />
</td>
</tr>
<tr id="1">
<td>1</td>
<td>Hotspot Avry Centre</td>
<td>../images/logos_hotspot/logo_wifi_avry.png</td>
<td>
<input type="button" value="supprimer" />
</td>
</tr>
</tbody>
</table>

最佳答案

我想这会对你有帮助

var MyRows = $('table#htmlTable').find('tbody').find('tr');
for (var i = 0; i < MyRows.length; i++) {
var MyIndexValue = $(MyRows[i]).find('td:eq(0)').html();
}

关于jquery - 如何使用JQuery获取html表格中的单元格值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20116547/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com