title: How can I use jQuery to determine if a click event fires within a specific element?
body: <p>I'm using the following code to animate a block.  In my code, <code>div_animate()</code> essentially hides a <code>&lt;div&gt;</code> with the specified selector if it is currently visible.  </p>
  
  <pre><code>$(document).click(function(event){
      div_animate("#container");
  });
  </code></pre>
  
  <p>I need to determine whether the user clicked on a child of <code>#container</code> and if so, <code>return false;</code> -- as far as I can tell, the code for this would look something like this:</p>
  
  <pre><code>$(document).click(function(event){
      if ( /* the event's target has a parent of #container */ ) {
          return false;
      } else {
          div_animate("#container");
      }
  });
  </code></pre>
  
  <p>Any thoughts?</p>