Does eq work if the form is being dynamically created?
<p>I have a form where people enter elements and it autogrows.  I wanted to do some math on the data being entered but I'm having problems capaturing the contents of the input field.  Here's the original program I'm working with ( <a href="http://jsfiddle.net/doktormolle/WaL84/" rel="nofollow">http://jsfiddle.net/doktormolle/WaL84/</a> ) and I did some reading and believe .eq is the command I need to get the second last element of the auto growing list(I can't get the last element because its always blank on a auto growing list).  </p>

<p>My end goal would be to take all the numbers and return the total or average,etc...</p>

<p>I tried <code>var from = $("#siblings").eq(-1).val();</code> and -2 but it keeps giving me the value of only the first cell(for example if I enter 1,2,3,4,5 on each cell then I'll keep getting 1).</p>

<p>If it helps here's the code:</p>

<pre><code>$(document).ready(function () {
    $("input[name='siblings']").on('keydown',
        function()
        {

           //is it the last input?
           if(this==$("input[name='siblings']:last",this.form)[0])
           {
            //insert an empty clone of the current input
            $(this).after($(this).clone(true).val(''));

           var from = $("#siblings").eq(-1).val();

           $("div#total").append("value = " + from + "&lt;br&gt;");       
           }
         });        
});
</code></pre>

<p>html:</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="input.js"&gt;
&lt;/script&gt;
&lt;style type="text/css"&gt;
input{display:block}​
&lt;/style&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt; test &lt;/p&gt;
&lt;form&gt;
    &lt;div id="inputform" name="inputform"&gt;
        &lt;input id="siblings" name="siblings"&gt; 
    &lt;/div&gt;
&lt;/form&gt;
&lt;div id="total"&gt;
hello
&lt;/div&gt;
&amp;nbsp;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
