title: Adding column to table with value from previous column in jquery
body: <p>I'm new in jquery and found this site as more helpful then others. I'm faced  problem adding column to the table. The added column should have consist the value from previous column. Here is code in JSFiddle <a href="http://jsfiddle.net/3sEGf/27/" rel="nofollow noreferrer">http://jsfiddle.net/3sEGf/27/</a>.</p>
  
  <p>HTML:</p>
  
  <pre><code> &lt;table border="1" class="table"&gt;
  &lt;thead&gt;
  &lt;tr&gt;
          &lt;th&gt;Repository&lt;/th&gt;
          &lt;th&gt; File 1&lt;/th&gt;
  
          &lt;th&gt;&lt;button  class="addColumn"&gt;Add Column&lt;/button&gt;&lt;/th&gt;&lt;/tr&gt;
  &lt;/thead&gt;
   &lt;tbody&gt;
          &lt;tr&gt;
          &lt;td&gt;Publish date&lt;/td&gt;&lt;td&gt;2/14/2013&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
          &lt;td&gt;Project&lt;/td&gt;&lt;td id="two"&gt;&lt;select id="select1"&gt;
  &lt;option value=""&gt;Pick one&lt;/option&gt;
  &lt;option value="1"&gt;False&lt;/option&gt;
  &lt;option value="2"&gt;True&lt;/option&gt;
  &lt;/select&gt;&lt;/td&gt;
           &lt;/tr&gt;
           &lt;tr&gt;
          &lt;td&gt;Title&lt;/td&gt;&lt;td&gt;Some info&lt;/td&gt;
           &lt;/tr&gt;  
  &lt;/tbody&gt;         
  &lt;/table&gt;
  </code></pre>
  
  <p>Jquery:</p>
  
  <pre><code>$(document).ready(function(){
  $("table.table button.addColumn").click(function () {
      var $this = $(this), $table = $this.closest('table')
      var columnName = window.prompt("Enter Column name", "");
  
      $('&lt;th&gt;' + columnName +'&lt;/th&gt;').insertBefore($table.find('tr').first().find('th:last'))
  
       var contentvalue = $(this).find("td:first").html();    
  
       $('&lt;td&gt;' + contentvalue + '&lt;/td&gt;').insertAfter($table.find('tr:gt(0)').find('td:last'))
  
  }); });
  </code></pre>