title: jquery event.target is_a_child_of(element)
body: <p>Given <code>element</code>, a variable containing a javascript object/DOM element, how do I determine if the event.target is an element inside <code>element</code> or not?</p>
  
  <pre><code>function(event){
     // assume that var element exists in this scope
     if(event.target == a_child_of(element))
        // do something
  }
  
  
  &lt;div id="myDiv"&gt;
     &lt;div class="innerDiv"&gt;
        &lt;input type="text"/&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>If <code>element</code> is <code>myDiv</code>, an event occurring on the inner div or the input, or any other element that may exist inside <code>myDiv</code> should cause the statement to evaluate to true.</p>
  
  <p>I imagine that I could use a recursive function to build an array of child elements and then check if the event.target is in the array, but I want to see if there's a simpler answer first.</p>