title: How to check and disable several checkboxes with jQuery?
body: <p>I have the following HTML code:</p>
  
  <pre><code>&lt;input type="checkbox" value="1" /&gt;
  &lt;input type="checkbox" value="2" /&gt;
  ...
  &lt;input type="checkbox" value="30" /&gt;
  </code></pre>
  
  <p>and the user has checked some of the boxes in a previous visit, and those values are stored in a variable (gets its value from the server): </p>
  
  <pre><code>myChoices = ["1", "5", "12"]
  </code></pre>
  
  <p>It is easy to check all checkboxes that have a value in myChoices, it can be done with:</p>
  
  <pre><code>$.(':checkbox').val(myChoices)
  </code></pre>
  
  <p>But I want to both check and disable these boxes. I do have a solution like follows:</p>
  
  <pre><code>$(':checkbox').each(function()
             {if ($.inArray(this.value, myChoices) != -1)
                  {this.checked=true; this.disabled=true;}
  })
  </code></pre>
  
  <p>It works fine, but I was simply wondering whether there is a simpler solution, something similar to val(), which is so elegant.</p>
  
  <p>Thanks.</p>