title: Detect if I'm clicking an element within an element
body: <p>I have an element (let's say div with id "Test") with a set height and width. Randomly placed within this element are other (smaller) elements (let's say id's "inner1","inner2","inner3"), but there is also whitespace, space where no elements are. I would like to have a function that fires upon clicking the main element, but then detect wether i'm clicking whitespace, or if not, clicking an inner element and if so, return the id of the inner element.</p>
  
  <p>Oh and the inner elements are dynamically generated so i don't know the id's before hand, i do know they are either div's or spans... (just as example as well, but i will have multiple types of elements).</p>
  
  <p>Thanks everyone.</p>
  
  <p>EDIT: (since thank you  Xotic750  for reminding me to post what i mean :))</p>
  
  <p>I haven't tried much since i have no idea how to call detect an inner click through the javascript..</p>
  
  <p>but here is an example:</p>
  
  <pre><code>&lt;div id="test"&gt;
      &lt;div id="inner1"&gt;&lt;/div&gt;
      &lt;span id="inner2"&gt;&lt;/span&gt;
      &lt;div id="inner3"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;style&gt;
  div#test {
      width:300px;
      height:400px;
      position:relative;
      display:block;
      border:1px solid blue;
  }
  div#test div, div#test span {
      display:block;
      position:absolute;
      border:1px solid red;
  }
  div#inner1 {
      top:15px;
      left:15px;
      height:15px;
      width:15px;
  }
  span#inner2 {
      top:65px;
      left:65px;
      height:15px;
      width:15px;
  }
  div#inner3 {
      top:155px;
      left:155px;
      height:15px;
      width:15px;
  }
  &lt;/style&gt;
  </code></pre>
  
  <p><a href="http://jsfiddle.net/BgbRy/2/" rel="noreferrer">http://jsfiddle.net/BgbRy/2/</a></p>