こんにちは私のシステムは、親のリストを含む春のmavenプロジェクトで構成されており、 th: timeleafテンプレートエンジンを使用してhtmlページに表示されます 。問題は、最初のボタンでのみ機能することです。私が試したボタンの残りの部分は機能しません以下のコード
脚本
$(document).ready(function(){
$("#button").attr("name").click(function(){
alert($(this).attr("name"));
});
});
タイムリーフ反復子を持つテーブル
<table class="table">
<tr>
<th>Parent Name</th>
<!-- <th>Country</th> -->
<!-- <th>State</th>
<th>District</th> -->
<th>Address</th>
<th>Phone No</th>
<th>Email</th>
<th>Active/Inactive</th>
<th></th>
</tr>
<tr th:each=" parent : ${parentList}">
<td th:text="${parent.parentName}"></td>
<!-- <td th:text="${parent.district.state.country.countryName}"></td> -->
<!-- <td th:text="${parent.district.state.stateName}"></td>
<td th:text="${parent.district.districtName}"></td> -->
<td th:text="${parent.parentAddress}"></td>
<td th:text="${parent.parentPhone}"></td>
<td th:text="${parent.parentEmail}"></td>
<td><a id="button" href="#" class="btn btn-small"
th:value="${parent.id}" th:name="${parent.id}" th:text="${parent.id}"></a></td>
</tr>
</table>