jQuery Form How to - Disable checkbox








Question

We would like to know how to disable checkbox.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--  w w  w  .ja va 2  s  . c  om-->
    $('.cb').attr('disabled',true);
});
</script>
</head>
<body>
  <input class="cb" type="checkbox" />
</body>
</html>

The code above is rendered as follows: