JQuery add row to table and bind event to last item only
<p>I am trying to append a copy of a select menu to the bottom of a table when a selection is made in the last select menu in the list. At this point I'd only like to apply the behaviour to the last select menu in the table. The code below adds in the row to the table but fails to unbind the action successfully, and as a result the first select menu continues to show the behaviour, even after the action has been unbound.</p>

<p>Javascript:</p>

<pre><code>var selectRow;
$(document).ready(function() {
    selectRow = $('#selectWrapper').html();
    rebindLastSelectBox();  
});

function rebindLastSelectBox() {
    $('#selectList:last').change(function(e) {   
       $(this).unbind('change');
        $('table').append("&lt;tr id='selectWrapper'&gt;" + selectRow + "&lt;/tr&gt;");
       rebindLastSelectBox();
   });
};
</code></pre>

<p>HTML:</p>

<pre><code>&lt;head&gt;
    &lt;title&gt;JS Test&lt;/title&gt;
    &lt;script src="./js/jquery.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt;
    &lt;script src="./js/application.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;table&gt;
    &lt;tr&gt;
     &lt;td&gt;Title&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="some_name" value="" id="some_name"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr id='selectWrapper'&gt; 
     &lt;td&gt;Items&lt;/td&gt;&lt;td&gt;&lt;select name="items[]" id="selectList" size="1"&gt;
      &lt;option value="1"&gt;Item 1&lt;/option&gt;
      &lt;option value="2"&gt;Item 2&lt;/option&gt;
     &lt;/select&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
</code></pre>

<p>All suggestions gratefully recieved!</p>

<p>Adam</p>
