我无法获取桌面上每个chekbox的值,即使我在其他页面上选中其他复选框,我也只获得焦点页面的值,但它不起作用。我想在提交表单时检查每个值。这就是我所拥有的:
function checkbox() {
var data = [];
$('.person_data').each(function() {
if (this.checked == true) {
data.push(this.value);
}
});
var str = data.join(', ');
$.ajax({
url: 'getcheck',
method: 'get',
ContentType: 'json',
data: {
check: str
},
success: function(response) {}
});
}
<table width="100%" class="table table-striped table-bordered table-hover" id="example">
<thead>
<tr>
<th><input type="checkbox" name="select_all" id="select_all" value="Tous"/> Tous</th>
<th style="width: 130px;">Module</th>
</thead>
<c:choose>
<c:when test="${fn:length(List)>0}">
<tbody>
<c:forEach items="${List}" var="var">
<tr>
<td>
<input type="checkbox" class="person_data" value="${var.id}"/>
</td>
<td><c:out value="${var.module}"></c:out><td>
</tr>
</c:forEach>
</tbody>
</c:when>
</c:choose>
</table>