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>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM