Disable all check boxes inside a table with jquery

前端 未结 7 1476
北海茫月
北海茫月 2021-01-04 11:09

I need to disable all the check boxes inside a table cell when clicking on a hyperlink inside the same table.

I\'m using the following jquery code to select all the

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-04 11:55

    // Enable/Disable All Checkboxes

    $('#checkbox').click(function() {
    
        var checked = $(this).attr('checked');
        var checkboxes = '.checkboxes input[type=checkbox]';
    
        if (checked) {
            $(this).attr('checked','checked');
            $(checkboxes).attr('disabled','true');
        } else {
            $(this).removeAttr('checked');
            $(checkboxes).removeAttr('disabled');
        }
    });
    

提交回复
热议问题