jQuery: setting checkbox values from array
<p>I am working on a script for setting checkboxes according to values stored in an array (part of a larger script for allowing the user to revert a form to its initial values). The code is basically this:</p>

<pre><code>$("#myForm :checkbox[name='myName[]']").each(function(){
    if($.inArray($(this).val(),initValues)!=-1){
        $(this).prop("checked",true);
    } else {
        $(this).prop("checked",false);
    }
});
</code></pre>

<p>initValues contains the value attributes of the boxes that were initially checked.</p>

<p>The script checks the first element in <code>$("#myForm :checkbox[name='myName[]']")</code> but subsequent elements all appear to be unchecked. Firebug shows that the <code>checked</code> attribute is being changed but the box itself is unchecked.</p>

<p>I have tried verious permutations of <code>attr()</code> in place of <code>prop()</code> all with the same results, and the script behaves the same way in Firefox 11.0 and Chrome 18.0 on OS X.</p>
