title: How do I combine logical OR with logical AND within a jQuery attribute selector?
body: <p>Given the following XML:</p>
  
  <pre><code>&lt;users&gt;
      &lt;user state="CA" sex="m"&gt;Max&lt;/user&gt;
      &lt;user state="AZ" sex="f"&gt;Jen&lt;/user&gt;
      &lt;user state="OR" sex="f"&gt;Kim&lt;/user&gt;
      &lt;user state="NV" sex="m"&gt;Bob&lt;/user&gt;
      &lt;user state="CA" sex="m"&gt;Jon&lt;/user&gt;
      &lt;user state="AZ" sex="m"&gt;Jim&lt;/user&gt;
      &lt;user state="OR" sex="f"&gt;Joy&lt;/user&gt;
      &lt;user state="NV" sex="f"&gt;Amy&lt;/user&gt;
  &lt;/users&gt;
  </code></pre>
  
  <p>Using jQuery, is there a way to select users who are male and are either from CA or NV, but without using the filter function? To be clear, I know that</p>
  
  <pre><code>$(xml).find("user[sex='m']")
  </code></pre>
  
  <p>selects only male users, while</p>
  
  <pre><code>$(xml).find("user[state='CA'],[state='NV']")
  </code></pre>
  
  <p>selects all users from either CA or NV. But I am not able to combine both of them with a logical AND within a single selector.</p>
  
  <p>Using the filter function, however, the following works:</p>
  
  <pre><code>$(xml).find("user").filter(function() {
      return $(this).attr('sex') == 'm' &amp;&amp; ($(this).attr('state') == 'CA' || $(this).attr('state') == 'NV')
  }).each(function() {
      alert($(this).text());
  });
  </code></pre>
  
  <p>Thanks!</p>