title: jQuery set checkbox checked
body: <p>I already tried all the possible ways, but I still didn't get it working.
  I have a modal window with a <code>checkbox</code> I want that when the modal opens, the <code>checkbox</code> check or uncheck should be based on a database value. (I have that already working with others form fields.) I started trying to get it checked but it didn't work.</p>
  <p>My HTML div:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div id=&quot;fModal&quot; class=&quot;modal&quot; &gt;
      ...
      &lt;div class=&quot;row-form&quot;&gt;
          &lt;div class=&quot;span12&quot;&gt;
              &lt;span class=&quot;top title&quot;&gt;Estado&lt;/span&gt;
  
            &lt;input type=&quot;checkbox&quot;  id=&quot;estado_cat&quot; class=&quot;ibtn&quot;&gt;
         &lt;/div&gt;
      &lt;/div&gt;             
  &lt;/div&gt;
  </code></pre>
  <p>and the jQuery:</p>
  <pre class="lang-js prettyprint-override"><code>$(&quot;#estado_cat&quot;).prop( &quot;checked&quot;, true );
  </code></pre>
  <p>I also tried with <code>attr</code>, and others seen here in the forums, but none seem to work.<br />
  Can someone point me the right way?</p>
  <hr />
  <h3>EDIT</h3>
  <p>OK, I'm really missing something here. I can check/uncheck using code if the check box is in the page, but is it's in the <em>modal</em> window, I can't. I tried dozens of different ways.</p>
  <p>I have a link that's supposed to open the modal:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;a href='#' data-id='&quot;.$row['id_cat'].&quot;' class='editButton icon-pencil'&gt;&lt;/a&gt;
  </code></pre>
  <p>and jQuery to &quot;listen&quot; the click and execute some operations like filling some text boxes with data coming from database. Everything works like I want but the problem is that I can't set checkbox checked/unchecked using code. Help please!</p>
  <pre class="lang-js prettyprint-override"><code>$(function () {
      $(&quot;.editButton&quot;).click(function () {
          var id = $(this).data('id');
          $.ajax({
              type: &quot;POST&quot;,
              url: &quot;process.php&quot;,
              dataType: &quot;json&quot;,
              data: {
                  id: id,
                  op: &quot;edit&quot;
              },
          }).done(function (data) {
              // The next two lines work fine,
              // i.e. it grabs the value from database and fills the textboxes
              $(&quot;#nome_categoria&quot;).val(data['nome_categoria']);
              $(&quot;#descricao_categoria&quot;).val(data['descricao_categoria']);
  
              // Then I tried to set the checkbox checked (because it's unchecked by default)
              // and it does not work
              $(&quot;#estado_cat&quot;).prop(&quot;checked&quot;, true);
              $('#fModal').modal('show');
          });
  
          evt.preventDefault();
          return false;
      });
  });
  </code></pre>