title: Get Contents of previous table outside div
body: <p>Below you find a piece of code. A container with two child div each containing a table. One is filled the other isn.'t. The [A] just above the second table should copy the contents of the first table into the second table. </p>
  
  <pre><code>&lt;div class="example-code"&gt;
     &lt;div class="content-box"&gt;
            &lt;div class="content-box-wrapper"&gt;
                   &lt;table id="carTable-20685519" data-car-id="20685519"&gt;
                          &lt;tr&gt;&lt;td&gt;Dummy Data 1 &lt;input type="text" name="car[20685519]"&lt;/td&gt;&lt;/tr&gt;       
                   &lt;/table&gt;
            &lt;/div&gt;
     &lt;/div&gt;
     &lt;div class="content-box"&gt;
            &lt;div class="content-box-wrapper"&gt;
                   &lt;a id="copy-20685519"&gt;Copy from above table&lt;/a&gt;
                   &lt;table id="carTable-206823698" data-car-id="206823698"&gt;    
                   &lt;/table&gt;
            &lt;/div&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I've created some JQuery for that. However, it looks like prev() doesn't search out outside the current div.. How can I get this working? </p>
  
  <pre><code>&lt;script&gt;
  
  $("a[id^='copy']").on('click', function () {
  
      console.log('Clicked');
  
      var id = $(this).next("table").attr('data-car-id'),
              previousId = $(this).prev('table').attr('data-car-id'),
      html = $(this).prev("table[id^='carTable-']").prop('innerHTML');
  
      $(this).next("table").html(html).find('input').each(function () {
          this.name = this.name.replace(previousId, id);
      });
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p><a href="http://jsfiddle.net/90jtudd4/" rel="nofollow">Demo in JSFiddle</a></p>