我使用jstl foreach循環顯示數據列表作爲表。在行的單擊中,行中的相應ID值需要發送到jquery onclick()函數。 表-1在使用jstl顯示的表中傳遞行ID到點擊行上的jquery
<table border="1" width="90%" class="table-hover" id="warehouseValue">
<tr>
<th>Warehouse Id</th>
<th>Warehouse Location</th>
<th>Warehouse City</th>
<th>Zone</th>
</tr>
<c:forEach items="${sessionScope.listWarehouse}" var="description">
<tr>
<td>
<input type="hidden" id="idValue" value="${description.getWarehouseId()}" />
${description.getWarehouseId()}
</td>
<td>${description.getWarehouseLocation()}</td>
<td>${description.getWarehouseCity()}</td>
<td>${description.getWarehouseDescription().getZone()}</td>
</tr>
</c:forEach>
</table>
jQuery的的onclick()上的任何行僅在第一行的id的點擊功能 -
$(document).ready(function() {
$("#warehouseValue").click(function() {
var rowId = document.getElementById("idValue").value;
alert("new "+rowId);
});
});
這裏 - $ {description.getWarehouseId()}是越來越顯示出來。 我如何使每行的相應Id值發送到onclick()函數
獲取新的[object Object]作爲輸出而不是Id –