简体   繁体   English

检查是否已选中“全选”复选框

[英]check if select all checkbox has been clicked

so i have a telerik client grid with a gridclientselectcolumn. 所以我有一个带有gridclientselectcolumn的telerik客户网格。 Im trying to figure out when the select all checkbox is clicked. 我试图找出何时单击全选复选框。

something like: 就像是:

function(sender, e){
if (e.SELECTALLCHECKBOX){
//do something
}

is there a way to simply check if the checkbox has been clicked. 有没有一种方法可以简单地检查复选框是否已被单击。

Thanks 谢谢

I hate to be the guy who always recommends jQuery but . 我讨厌成为总是推荐jQuery的人。 . . I would recommend jQuery. 我会推荐jQuery。

$('#selectAllCheckbox:checked').on('change', function(e) {
    if ($(this).prop('checked') {
        $('#otherCheckbox').prop('checked', true);
    }
    else {
        $('#otherCheckbox').prop('checked', false);
    }
}

Be careful about using .prop() as opposed to .val(). 使用.prop()而不是.val()时要小心。 There are some subtle differences that can get you in trouble. 有一些细微的差异会给您带来麻烦。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM