<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>