如何使用JQuery在html表中获取单元格值

前端之家收集整理的这篇文章主要介绍了如何使用JQuery在html表中获取单元格值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我看过很多关于我的问题的帖子,但任何一个对我都有用.

我有这个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();
}
原文链接:https://www.f2er.com/jquery/177003.html

猜你在找的jQuery相关文章