Get id of children
<p>I have made a dynamic system so you can append divs in divs in divs etc.
Now I want to know the id of the div when I click on it. I have made a script like this:
HTML:</p>

<pre><code>&lt;div id="div1" class="mod"&gt;   
  &lt;div id="div4" class="mod"&gt;
     &lt;div id="div5" class="mod"&gt;&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;div id="div2" class="mod"&gt;
   &lt;div id="div6" class="mod"&gt;
     &lt;div id="div7" class="mod"&gt;&lt;/div&gt;
   &lt;/div&gt;
&lt;/div&gt;
</code></pre>



<p>Jquery:</p>

<pre><code>$('.mod').click(function(){
  var id = $(this).attr('id');
  alert(id);
 });
</code></pre>

<p>If you click for example on div4 it will return div_4 and div_1 but I only want div_4 as return.
Can someone help me? I read something about parents and children but I can't figure it out.
Regards Frank</p>
