title: How do I check whether a checkbox is checked in jQuery?
body: <p>I need to check the <code>checked</code> property of a checkbox and perform an action based on the checked property using jQuery.</p>
  <p>For example, if the <code>age</code> checkbox is checked, then I need to show a textbox to enter <code>age</code>, else hide the textbox.</p>
  <p>But the following code returns <code>false</code> by default:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>if ($('#isAgeSelected').attr('checked')) {
    $("#txtAge").show();
  } else {
    $("#txtAge").hide();
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;input type="checkbox" id="isAgeSelected"/&gt;
  &lt;div id="txtAge" style="display:none"&gt;
    Age is selected
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>How do I successfully query the <code>checked</code> property?</p>