title: Get contents of php created div with variable id with JQuery
body: <p>On my page I have a search form which generates a table for the results. In that table, each cells content is surrounded by a span tag with an ID based on the cells name and rows ID in the database. In addition the span gets a fixed class. Heres a printed example:</p>
  
  <pre><code>&lt;td&gt;&lt;span id="firstname_203" class="text"&gt;John&lt;/span&gt;&lt;/td&gt;
  </code></pre>
  
  <p>What I am trying to do, is that when I hover the cell that contains the firstname, I want the firstname to appear on a different part of the page. I have tried the code below, but it only returns firstname=null:</p>
  
  <pre><code>( function($) {
      $(document).ready(function() 
      {
      $(".text").hover(function() 
      {
      var ID=$(this).attr('id');
      var firstname=$("#firstname_"+ID).html();
      $($(".firstname")).html("firstname="+firstname);
      });
  });
  } ) ( jQuery );
  </code></pre>
  
  <p>It's the ID part that doesn't work because if i hardcode the ID (e.g. "#firstname_203") it works just fine.</p>
  
  <p>When I think about it, the only thing I need to know is how to get the php generated integer following the ID.</p>
  
  <p>Update:</p>
  
  <p>When adding more variables (this).text didn't work as it returned the whole rows values. Instead I had to use this:</p>
  
  <pre><code>$("#table td:nth-child(1)").hover(function(event){
  </code></pre>
  
  <p>and return the cells as:</p>
  
  <pre><code>var firstname= $td.eq(0).text();
  </code></pre>
  
  <p>and so on.</p>