check for a value in all the child divs in a particular parent div
<p>In my project. I am trying to check whether a certain number already present in any other adjacent <code>div</code>'s which are present in a parent div.</p>

<pre><code>  //generated dynamically using jQuery
  &lt;div&gt; //parent div
      //many div's
      //one of the child div is selected by the user.
  &lt;/div&gt;
  &lt;div&gt; //another parent div
     //my function is checking one of these div's instead of the above, rarely
  &lt;/div&gt;
</code></pre>

<hr>

<p>I used the following below code. but it sometimes(rarely) selecting the another parent <code>div</code>'s child elements which I dont want to check for (I checked with debugger in chrome). and if sometimes even if the function selects the correct parent div it is always selecting the same child div element which is selected by the user.</p>

<p><strong>jQuery</strong></p>

<pre><code>function checkInGroup(){
    var selectedDiv = $('#' + _selectedDivId); //updated after engineer's comment
    selectedDiv.parent("div").children().each(function(){
        debugger;
        if(this !== selectedDiv[0]){ //selecting the same div
            var self = $(this);
            if(self.text() == _randomNumber){
                debugger; //never executing
                //do some function here
            }
        }
    });
}
</code></pre>

<p>EDIT:  I am not sure why my code is not working when it is working fine in <strong><a href="http://jsbin.com/iviwej/1/edit" rel="nofollow">jsbin</a></strong>. I need to check why so.. It is always checking with the same user selected div?? Hence the function is not entering into the if statement..</p>

<p>The <code>debugger</code> which is present inside the if statement is never executing. and also the each function loop is happening only once with the same selected div (hence the function is not entering in to the if statement)</p>

<p>Here is the <strong><a href="http://jsbin.com/iviwej/17/edit" rel="nofollow">jsfiddle</a></strong></p>
