jquery获取表格每一行数据

<table class="table">
    <tr>
        <th>ID</th>
        <th>描述</th>
        <th>操作</th>
    </tr>

    <tr th:each="question:${questions}">
        <td th:text="${question.id}"></td>
        <td th:text="${question.description}"></td>
        <td>
            <button id="suppId" type="button" class="btn btn-primary supp">提交</button>
        </td>
    </tr>
</table>

  

获取每一行的“描述”的值

<script>
        $(function () {
            $(".btn.btn-primary.supp").click(function () {
                var desc= $(this).parent().parent().find('td').eq(1).html();
                alert(desc);
            })
        })
</script>

  

posted @ 2020-12-06 09:30  Mr_sven  阅读(1977)  评论(0编辑  收藏  举报