title: How to select one child div by clicking on another child div of the same parent in jQuery?
body: <p>For example I have simple html.</p>
  
  <pre><code>&lt;body&gt;
      &lt;div class="a"&gt;
          &lt;div class="child"&gt;&lt;/div&gt; &lt;!-- div element I click --&gt;
          &lt;div class="childINeedToSelect"&gt;&lt;/div&gt; &lt;!-- div element I need to be selected --&gt;
          &lt;div class="child"&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="a"&gt;
          &lt;div class="child"&gt;&lt;/div&gt;
          &lt;div class="childINeedToSelect"&gt;&lt;/div&gt;
          &lt;div class="child"&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>When I click on top first <code>child</code> class div I need to change, for example, border <strong>ONLY</strong> of the first <code>childINeedToSelect</code> class div. They have the same parent - <code>a</code> class div, but the difficult is that there are more than just one element with class <code>a</code>. I've already tried:</p>
  
  <pre><code>$(document).ready(function () {
      var child = $('.child');
      child.bind('click', function() {
          detectElement($(this));
      });
  });
  
  var belt;
  function detectElement(arrow) {
      belt = arrow.parent('.a').children('childINeedToSelect').eq(1);
      belt.css("background-color", "red");
  }
  </code></pre>
  
  <p>As you see I'm trying to send <code>$(this)</code> as parameter to <code>detectElement()</code> to determine which div was clicked. But my target <code>div</code> background doesn't change, and when I try to use element <code>belt</code> later, after it was <em>detected</em> by <code>detectElement()</code> function, Opera javascript debugger gives me error </p>
  
  <pre><code>Unhandled Error: Cannot convert 'belt.css('marginLeft')' to object
  </code></pre>
  
  <p>in line </p>
  
  <pre><code>var currentMargin = parseInt(belt.css('marginLeft').toString().replace('px', ''));
  </code></pre>
  
  <p>but this line of code worked perfectly, before calling <code>detectElement()</code> function; What am I doing wrong? How should I select element I need?</p>