Jquery how to count checked and disable checkboxes

后端 未结 7 1439
有刺的猬
有刺的猬 2021-02-15 12:29

I am trying to disable all unchecked checkboxes when there are 5 checked checkboxes.

My code is not working here it is: http://jsfiddle.net/mtYtW/18/

My Jquery:

7条回答
  •  迷失自我
    2021-02-15 13:15

    $("table input[type=checkbox]").click(function(){
        var countchecked = $("table input[type=checkbox]:checked").length;
        if(countchecked >= 5) {
            $("table input:checkbox").attr("disabled", true);
        }else{
    
        }
    });
    

    Working example: http://jsfiddle.net/Re5uy/6/

提交回复
热议问题