How to check checkbox in jQuery
<p>Hi i'm using jQuery in my asp.net mvc application, in this i have created some checkboxes like</p>

<pre><code>$("#dvModules").append('&lt;input type="checkbox" id=Module_' + jsModulesData[ctr].Code + ' name="' + jsModulesData[ctr].Name + '" value="' + jsModulesData[ctr].Code + '"&gt; ' + jsModulesData[ctr].Name + '
');
</code></pre>

<p>i checked some of them and stored its values in database, when i enter it to this page again, i got the values from the database, but i could not check the corresponding checkboxes with their values my code is below:</p>

<pre><code>var arrModuleIDs = SelectedModuleIDs.split(',');

$(document).ready(function () {
    SelectedModuleIDs = '@ViewBag.SelectedModuleIDs';
    var arrModuleIDs = SelectedModuleIDs.split(',');

    for (var i = 0; i &lt; arrModuleIDs.length; i++) {
        $("#Module_" + arrModuleIDs[i] + "").attr('checked', true);
         //Here the arrmoduleIDs is the values from database.
    }
</code></pre>

<p>here the loop is performing well but the checkbox is not checked,
can anyone help me to resolve this.</p>
