Select all checkbox elements except disabled ones

后端 未结 8 476
暗喜
暗喜 2021-01-18 09:06

I want to select all checkbox elements expect disabled ones,

this is my html



        
8条回答
  •  无人及你
    2021-01-18 09:45

    I'd personally suggest:

    $('#chkSelectAll').change(function(){
        var self = this;
        $('input:checkbox').filter(function(){
            return !this.disabled
        }).prop('checked',self.checked);
    });
    

    JS Fiddle demo.

    References:

    • change().
    • :checkbox.
    • filter().

提交回复
热议问题