title: jQuery - Get table cell value
body: <p>I have a table which looks like the following. The price normally comes from a database this is just for showing the problem I have.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
      $(document).delegate('.amount input[type="text"]','keyup',(function() {
          var $this = $(this);
          var sub_total = $this.find('.sub_total');
          var price = $this.find('.price').text();
          var amount = $this.val();
          alert(price);
      }));
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;table&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;input type="text" name="tickets" id="tickets" class="amount" maxlength="2" autocomplete="off"&gt;&lt;/td&gt;
        &lt;td&gt;Ticket:&lt;/td&gt;
        &lt;td class="price"&gt;20,50&lt;/td&gt;
        &lt;td class="sub_total"&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>What I would like to do is: when the user types a number in the field <code>tickets</code> it should update the field <code>sub_total</code>. With the jQuery I have this is not working. When I <code>alert(price)</code> I get <code>undefined</code>. So I wonder how to make the <code>sub_total</code> field with auto updated values. It might also be interesting to know that I have more rows like this beneath this row. So the script should only update the field from one specific row at a time.</p>
  
  <p>What I already tried but without success:
  <a href="https://stackoverflow.com/questions/5612128/how-to-get-a-table-cell-value-using-jquery">How to get a table cell value using jQuery</a>;
  <a href="https://stackoverflow.com/questions/376081/how-to-get-a-table-cell-value-using-jquery">How to get a table cell value using jQuery?</a>;
  <a href="https://stackoverflow.com/questions/18874185/how-to-get-table-cell-values-any-where-in-the-table-using-jquery">How to get table cell values any where in the table using jquery</a></p>
  
  <p>Thanks in advance.</p>