How to loop through multiple divs
<p>I have a structure like this :</p>

<pre><code>&lt;div&gt;
     &lt;div&gt; 
         &lt;div onclick="someFunction(this)"&gt;&lt;/div&gt;
     &lt;/div&gt;
     &lt;div&gt; 
         &lt;div onclick="someFunction(this)"&gt;&lt;/div&gt;
     &lt;/div&gt;
     ..
     ..
&lt;/div&gt;
</code></pre>

<p>So inside my <code>someFunction()</code>, how do I iterate through all the <code>div</code>s that have the <code>onclick</code> implemented on them?</p>

<p>I've thought of the following:</p>

<pre><code>$(this).parent().parent().children().each( function () { } );
</code></pre>

<p>But somehow I'm totally sure that it's wrong. Because doing <code>parent()</code> twice might take me to the topmost parent, but after that iterating through each child won't actually iterate through all of the <code>div</code>s that have <code>onclick</code> on them, instead, it'll iterate through the <code>div</code>s one level above it. And if I do <code>children()</code> again and then do <code>each()</code>, I don't think it'll do what I want.
Please guide.</p>
