jQuery Form How to - Disable input control








Question

We would like to know how to disable input control.

Answer


 <!-- ww  w.j a  v  a 2s. c o m-->
<html>
  <head>
    <script type="text/javascript" src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type="text/javascript">
      $(document).ready(function(){
          $("input").attr("disabled", "disabled");
      });
    </script>
  </head>
  <body>
   <form>
    <input type="checkbox" name="a" />
    <span>A</span>
    <input type="checkbox" name="b" />
    <span>B</span>
    <input type="checkbox" name="c" checked="checked" />
    <span>C</span>
  </form>
  </body>
</html>

The code above is rendered as follows: