JS如何实现全选反选
<th style="width:25px;"><input type="checkbox" class="group-checkable fakebtn" id="selectAll" onclick="allSelect();"/></th>
<td><input type="checkbox" class="checkboxes" name="ids" onclick="dataSum();" value="${vo.id }" /></td>``
//全选反选
function allSelect(){
if($("#selectAll").prop("checked")){
$('input:checkbox[name=ids]').each(function(k){
var parentTd=$(this).parent();
var tr=parentTd.parent();
var amount=tr.find('td').eq(4).text();
amountSum = amountSum+parseFloat(amount);
var price=tr.find('td').eq(8).text();
priceSum = priceSum+parseFloat(price);
})
$("#amountSum").text(amountSum.toFixed(4));
$("#priceSum").text(priceSum.toFixed(2)+"元");
}
}
//单选
function dataSum(){
var amountSum=0;
var priceSum=0;
$('input:checkbox[name=ids]:checked').each(function(k){
var parentTd=$(this).parent();
var tr=parentTd.parent();
var amount=tr.find('td').eq(4).text();
amountSum = amountSum+parseFloat(amount);
var price=tr.find('td').eq(8).text();
priceSum = priceSum+parseFloat(price);
})
$("#amountSum").text(amountSum.toFixed(4));
$("#priceSum").text(priceSum.toFixed(2)+"元");
}