title: How to write if/else with jquery selector?
body: <p>I need to write simple if/else in one line and simpler using jQuery selector. How can I do it?</p>
  
  <p>I have a checkbox named <code>chkAgree</code> in my form. I am trying to handle its click event like below. I would like to write this code block more simpler with just once using jQuery selector. My IDE gives me warning that "Duplicated jQuery selector", so I think there is a way to solve this problem.
  Regards</p>
  
  <pre><code>$("#chkAgree").click(function() {
      if (this.checked) {
          $("#divCheckboxes").show();
      } else {
          $("#divCheckboxes").hide();
      }
  });
  </code></pre>