// A code block
1
// An highlighted block
//点击全选按钮全选事件
$("#checkAll").click(function () {
$("input[name='childCheck']").prop("checked",this.checked);
})
//点击tr栏,获取复选框点击事件//name表示属性选择
$("#activityBody").on('click',"input[name = 'childCheck']",function () {
/*比较当前页中所有的个数和选中的个数
* checked:是input标签的一个属性,默认值为true,表示选中的。
* $("input[name='childCheck']:checked").length选中的复选框的长度
* */
$("#checkAll").prop("checked",$("input[name='childCheck']").length==
$("input[name='childCheck']:checked").length)
})
*下面是节选片段
:主要需要在的input标签中加上type=“checkbox”
效果图
// An highlighted block
//封装分页查询
function pageList(pageSize,pageNo ) {
//把全选框改为默认的,不勾选
$("#checkAll").prop('checked',false);
//获取隐藏域中的数据
var fullname = $("#hidden-fullname").val();
var company = $("#hidden-company").val();
var phone = $("#hidden-phone").val();
var state = $("#hidden-state").val();
var mphone = $("#hidden-mphone").val();
var owner = $("#hidden-owner").val();
var source = $("#hidden-source").val();
$.ajax({
url:'/clue/page',
type:'get',
data: {
pageSize:pageSize,
pageNo:pageNo,
fullname:$.trim($("#search-fullname").val()),
company:$.trim($("#search-company").val()),
phone:$.trim($("#search-phone").val()),
source:$.trim($("#search-source").val()),
owner:$.trim($("#search-owner").val()),
mphone:$.trim($("#search-mphone").val()),/*页面请求的参数*/
state:$.trim($("#search-state").val())
},
dataType:'json',
success:function (obj) {
if ( obj.message=='OK' ){
if (obj.data != null) {
var items = obj.data.rows;
var html ='';
for(var i in items){
html+='<tr>'
html+='<td><input name="childCheck" type="checkbox" value="'+items[i].id+'"/></td>'
html+='<td><a style="text-decoration: none; cursor: pointer;" ' +
'οnclick="window.location.href=\'detail.html\'">'+items[i].fullname+""+items[i].appellation+'</a></td>'
html+='<td>'+items[i].company+'</td>'
html+='<td>'+items[i].phone+'</td>'
html+='<td>'+items[i].mphone+'</td>'
html+='<td>'+items[i].source+'</td>'
html+='<td>'+items[i].owner+'</td>'
html+='<td>'+items[i].state+'</td>'
html+='</tr>'
}
$("#activityBody").html(html);
//总页面数=总记录数/每页记录数
var totalPages = obj.data.total%pageSize==0?(obj.data.total/pageSize):(obj.data.total/pageSize)+1;
$("#activityPage").bs_pagination({
currentPage: pageNo, // 页码
rowsPerPage: pageSize, // 每页显示的记录条数
maxRowsPerPage: 20, // 每页最多显示的记录条数
totalPages: totalPages, // 总页数
totalRows: obj.data.total, // 总记录条数
visiblePageLinks:4, // 显示几个卡片
showGoToPage: true,
showRowsPerPage: true,
showRowsInfo: true,
showRowsDefaultInfo: true,
onChangePage : function(event, obj){
pageList(obj.rowsPerPage,obj.currentPage);
}
});
}
}
}
})
```_