title: How to disable a textbox if a checkbox is checked using jQuery?
body: <p>I want to disable a textbox if a user unchecks a checkbox and change the background colour of textbox. If the user checks the checkbox then that textbox should be editable and changes to white colour.
  Here is the code</p>
  
  <pre><code>$(document).ready(function () {
      $(".ba").click(function () {
          $(".tex").css("background-color", "#CCCCCC");
      });
  });
  </code></pre>
  
  <p>Where <strong>.ba</strong> is the checkbox and <strong>.tex</strong> is textbox classes, now when the user clicks it changes to grey color but if they click again the color not changing.I want to see if the check box is checked if it is checked then nothing should happen else if the user uncheck the check box the textbox background color should change and it should go to non-editable that is disabled.Can anyone help?</p>
  
  <p>I am using Below javascript to check all and uncheck all</p>
  
  <pre><code>function checkAll(formname, checktoggle) {
      var checkboxes = new Array(); 
      checkboxes = document[formname].getElementsByTagName('input');
  
      for (var i=0; i&lt;checkboxes.length; i++)  {
          if (checkboxes[i].type == 'checkbox')   {
              checkboxes[i].checked = checktoggle;
          }
      }
  }
  </code></pre>
  
  <p>Is this causes any problem?</p>