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:
The following should do the trick for your needs:
$("table input[type=checkbox]").click(function(){
var countchecked = $("table input[type=checkbox]:checked").length;
if(countchecked >= 5)
{
$('table input[type=checkbox]').not(':checked').attr("disabled",true);
}
else
{
$('table input[type=checkbox]').not(':checked').attr("disabled",false);
}
});
Example for your needs
(Generic) The following will disable all of your unchecked checkboxes:
$('input[type=checkbox]').not(':checked').attr("disabled","disabled");
Generic Disable Example