<table>
<thead>
<tr>
<th><input type="checkbox" id="checkMIds" name="checkMIds"
style=" width: 15px; height: 15px; left: 15px; margin-top: -10px;background: #3DD4F3; border: #3DD4F3"
οnclick="checkMAll()" /></th>
<th>序号</th>
</tr>
</thead>
<tbody>
<tr>
<td> <input type="checkbox" id="checkMIds" name="checkMIds"
style=" width: 15px; height: 15px; left: 15px; margin-top: -10px;background: #3DD4F3; border: #3DD4F3"
/></td>
<td></td>
</tr>
</tbody>
</table>
table 控件添加checkbox 有时可能会不显示 需要将checkbox控件的visibility设置为visible(可见)
<input type="checkbox" name="checkStoreId"
style="visibility: visible; width: 15px; height: 15px; left: 15px; margin-top: -10px;background: #3DD4F3; border: #3DD4F3"
οnclick="checkMAll()" />
checkbox全选办法
此方法可以有效避免一次选中后选中效果失效
function checkMAll(){
var isChecked = $('#checkMIds').is(':checked');
$("input[name='checkStoreId']").prop("checked", isChecked);
}
获取选中的值 我的checkbox的name是checkStoreId
var data2=[];
$("input[name='checkStoreId']:checkbox:checked").each(function(i){
data2[i]=$(this).val();
});
ajax发送请求时参数是数组 需要设置 traditional: true
$.ajax({
type: "POST",
url: "list.action",
data: { "storeIds":data2 },
dataType:"json",
traditional: true,
success: function(msg){}
});
<thead>
<tr>
<th><input type="checkbox" id="checkMIds" name="checkMIds"
style=" width: 15px; height: 15px; left: 15px; margin-top: -10px;background: #3DD4F3; border: #3DD4F3"
οnclick="checkMAll()" /></th>
<th>序号</th>
</tr>
</thead>
<tbody>
<tr>
<td> <input type="checkbox" id="checkMIds" name="checkMIds"
style=" width: 15px; height: 15px; left: 15px; margin-top: -10px;background: #3DD4F3; border: #3DD4F3"
/></td>
<td></td>
</tr>
</tbody>
</table>
table 控件添加checkbox 有时可能会不显示 需要将checkbox控件的visibility设置为visible(可见)
<input type="checkbox" name="checkStoreId"
style="visibility: visible; width: 15px; height: 15px; left: 15px; margin-top: -10px;background: #3DD4F3; border: #3DD4F3"
οnclick="checkMAll()" />
checkbox全选办法
此方法可以有效避免一次选中后选中效果失效
function checkMAll(){
var isChecked = $('#checkMIds').is(':checked');
$("input[name='checkStoreId']").prop("checked", isChecked);
}
获取选中的值 我的checkbox的name是checkStoreId
var data2=[];
$("input[name='checkStoreId']:checkbox:checked").each(function(i){
data2[i]=$(this).val();
});
ajax发送请求时参数是数组 需要设置 traditional: true
$.ajax({
type: "POST",
url: "list.action",
data: { "storeIds":data2 },
dataType:"json",
traditional: true,
success: function(msg){}
});