title: How to detect the div in which a link to a javascript function has been clicked
body: <p>I have the following html code:</p>
  
  <pre><code>&lt;div id="result1" class="result"&gt;
      ... some html ...
      ... &lt;a href="javascript:updateNext(this, uri);"&gt;link&lt;/a&gt;
      ... some html ...
  &lt;/div&gt;
  &lt;div id="result2" class="result"&gt;
      ... some html ...
      ... &lt;a href="javascript:updateNext(this, uri);"&gt;link&lt;/a&gt;
      ... some html ...
  &lt;/div&gt;
  &lt;div id="result3" class="result"&gt;
  &lt;/div&gt;
  &lt;div id="result4" class="result"&gt;
  &lt;/div&gt;    
  </code></pre>
  
  <p>The goal is to update the content of the next div when I click on the link. So for instance, when I click on a link in #result2, the content of #result3 will be updated.</p>
  
  <p>Here is the javascript function:</p>
  
  <pre><code>&lt;script&gt;
              function updateNext(elem, uri) {
                      $.ajax({
                              url: uri,
                              success: function(data) {
                                      elem.closest('.result').nextAll().html('');
                                      elem.closest('.result').next().html(data);
                              }
                      });
              }
  &lt;/script&gt;
  </code></pre>
  
  <p>However, when I use the link, elem is set as the window, not the link itself.</p>
  
  <p>The content of the div is generated by a server which should not know the position of the div in which the code he is generating will be.</p>
  
  <p>I also tried with a </p>
  
  <pre><code> &lt;a href="javascript:" onclick="updateNext(...
  </code></pre>
  
  <p>with no other result...</p>
  
  <p>any idea ? :-)</p>
  
  <p>Thanks,</p>
  
  <p>Arnaud.</p>