您的位置:首页 > Web前端 > JQuery

jquery 实现gridview checkbox 全选功能

2012-05-29 10:52 801 查看
$(document).ready(function () {
$("#gv tr:first th:first").find('[type="checkbox"]').click(function () { //gridView命名为gv
if ($(this).attr("checked")) {
$("#gv").find('[type="checkbox"]').not('[checked="true"]').attr("checked", "true");
}
else {
$("#gv").find('[type="checkbox"]').removeAttr("checked");
}
})

$("#gv tr").not(':first').find('[type="checkbox"]').click(function () {
var checkCount = $("#gv tr").not(':first').find('[type="checkbox"][checked="true"]').size();
if (checkCount == $("#gv tr").not(':first').find('[type="checkbox"]').size()) {
$("#gv tr:first th:first").find('[type="checkbox"]').attr("checked", "true");
}
else {
$("#gv tr:first th:first").find('[type="checkbox"]').removeAttr("checked");
}
})
})
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: