Issue Removing Dynamically Create Element
<p>I'm having an issue with having 2 sets of dynamically created elements. I have an unordered list (displays item) and a hidden form with a fieldset. When an item is added it replaces the list element and clones the fieldset and adds item values to it.</p>

<p>Original HTML </p>

<pre><code>&lt;div id="lp-orderform"&gt;
   &lt;h1&gt;Cart&lt;/h1&gt;
      &lt;ul id="cart-items"&gt;
         &lt;li id="emptycart"&gt;You have no items in your cart.&lt;/li&gt;
      &lt;/ul&gt;
&lt;/div&gt;

&lt;form id="lunch_orderform" method="post" action="" enctype="multipart/form-data"&gt;
   &lt;input type="hidden" id="title" name="title" value=""&gt;
   &lt;input type="hidden" id="lunch_order_id" name="lunch_order_id" value=""&gt;
   &lt;input type="hidden" id="lunch_ordered_by" name="lunch_ordered_by" value="Phil Ecker"&gt;
   &lt;input type="hidden" id="lunch_ordered_by_email" name="lunch_ordered_by_email" value=""&gt;
   &lt;input type="hidden" id="lunch_ordered_by_extension" name="lunch_ordered_by_extension" value=""&gt;
   &lt;input type="hidden" id="entry_date" name="entry_date" value="2013-04-15 09:22 AM" class="hasDatepicker"&gt;
   &lt;input type="hidden" id="lunch_order_date" name="lunch_order_date" value="2013-04-08 11:42 AM" class="hasDatepicker"&gt;
   &lt;input type="hidden" id="lunch_order_vendor" name="lunch_order_vendor" value=""&gt;
   &lt;input type="hidden" id="lunch_order_share_id" name="lunch_order_share_id" value=""&gt;
   &lt;input type="hidden" id="lunch_order_account_number" name="lunch_order_account_number" value=""&gt;
   &lt;input type="hidden" id="lunch_order_subtotal" name="lunch_order_subtotal" value=""&gt;      
   &lt;input type="hidden" id="lunch_order_tax" name="lunch_order_tax" value=""&gt;
   &lt;input type="hidden" id="lunch_order_delivery_fee" name="lunch_order_delivery_fee" value=""&gt;
   &lt;input type="hidden" id="lunch_order_total" name="lunch_order_total" value=""&gt;
   &lt;input type="hidden" id="lunch_formatted_order_total" name="lunch_formatted_order_total" value=""&gt;

  &lt;fieldset class="lunch_items_ordered"&gt;
      &lt;input type="hidden" name="lunch_items_ordered[row_order][]" value="row_new_0"&gt;
      &lt;input type="hidden" name="lunch_items_ordered[row_new_0][col_id_23]" id="lunchorder_item_entry_id" value=""&gt;
      &lt;input type="hidden" name="lunch_items_ordered[row_new_0][col_id_24]" id="lunchorder_item_title" value=""&gt;
      &lt;input type="hidden" name="lunch_items_ordered[row_new_0][col_id_28]" id="lunchorder_item_quantity" value=""&gt;
      &lt;input type="hidden" name="lunch_items_ordered[row_new_0][col_id_25]" id="lunchorder_item_price" value=""&gt;
      &lt;input type="hidden" name="lunch_items_ordered[row_new_0][col_id_26]" id="lunchorder_item_options" value=""&gt;
      &lt;input type="hidden" name="lunch_items_ordered[row_new_0][col_id_27]" id="lunchorder_item_comments" value=""&gt;
  &lt;/fieldset&gt;

  &lt;input type="submit" value="Place Order"&gt;
&lt;/form&gt;
</code></pre>

<p>jQuery - Add Display Element</p>

<pre><code>$(".detail-view button").on("click", function(){
  var noItems = $("ul#cart-items li").eq(0).attr("id");
  var detailID = $(this).attr('id');

  var orderTitle = $("#detail-"+ detailID + " span.order-title").text();
  var insertTitle = $("&lt;li&gt;&lt;a href=\"#\"&gt;&lt;img src=\"/assets/images/global/intra_remove_item_btn.png\" /&gt;&lt;/a&gt;"+ orderTitle +"&lt;/li&gt;").attr("id", detailID);

  if(noItems == "emptycart") {
     $("ul#cart-items li#emptycart").replaceWith(insertTitle);
     $("#lp-orderform li:even").addClass("highlight");
  } else {
     $(insertTitle).insertAfter("ul#cart-items li:last");
     $("#lp-orderform li:even").addClass("highlight");
  }
});
</code></pre>

<p>jQuery - Clone Fieldset</p>

<pre><code>$(".detail-view button").on("click", function() {
  var detailID = $(this).attr('id');

  var orderEntryId = $("#detail-"+ detailID + " span.order-entryid").text();
  var orderTitle = $("#detail-"+ detailID + " span.order-title").text();
  var orderQuantity = $("#detail-"+ detailID + " span.order-quantity option:selected").text();
  var orderPrice = $("#detail-"+ detailID + " span.order-price").text();
  var orderOptions = $("#detail-"+ detailID + " span.order-options option:selected").text();
  var orderComments = $("#detail-"+ detailID + " span.order-comments textarea").val();

  var quantityPrice = parseFloat(orderQuantity*orderPrice).toFixed(2);

  addItem();
  closeFancyBox();

  function closeFancyBox(){
    $.fancybox.close();
  }

  function addItem() {
    var itemID = $("input#lunchorder_item_entry_id").val();

    if(itemID == "") {
        orderDetail();
    } else {
       $("fieldset.lunch_items_ordered:last").clone().val("").insertAfter("fieldset.lunch_items_ordered:last");
       nameCounter();

       function nameCounter() {
           var rowValueCount = $("fieldset.lunch_items_ordered:last input").eq(0).val();

           var newValueCount = rowValueCount.replace(/(\d+)$/, function(fullMatch, n) {
               return Number(n) + 1;
           });

           $("fieldset.lunch_items_ordered:last input").eq(0).val(newValueCount);

           $("fieldset.lunch_items_ordered:last input").eq(1).attr("name", "lunch_items_ordered["+ newValueCount +"][col_id_23]");
           $("fieldset.lunch_items_ordered:last input").eq(2).attr("name", "lunch_items_ordered["+ newValueCount +"][col_id_24]");
           $("fieldset.lunch_items_ordered:last input").eq(3).attr("name", "lunch_items_ordered["+ newValueCount +"][col_id_28]");
           $("fieldset.lunch_items_ordered:last input").eq(4).attr("name", "lunch_items_ordered["+ newValueCount +"][col_id_25]");
           $("fieldset.lunch_items_ordered:last input").eq(5).attr("name", "lunch_items_ordered["+ newValueCount +"][col_id_26]");
           $("fieldset.lunch_items_ordered:last input").eq(6).attr("name", "lunch_items_ordered["+ newValueCount +"][col_id_27]");
       }

       orderDetail();
    }
    }

    function orderDetail() {
     $("fieldset.lunch_items_ordered:last input#lunchorder_item_entry_id").val(orderEntryId);
     $("fieldset.lunch_items_ordered:last input#lunchorder_item_title").val(orderTitle);
     $("fieldset.lunch_items_ordered:last input#lunchorder_item_quantity").val(orderQuantity);
     $("fieldset.lunch_items_ordered:last input#lunchorder_item_price").val(quantityPrice);
     $("fieldset.lunch_items_ordered:last input#lunchorder_item_options").val(orderOptions);
     $("fieldset.lunch_items_ordered:last input#lunchorder_item_comments").val(orderComments); 
  }
});
</code></pre>

<p>I believe my issue is with the following block of jQuery:</p>

<pre><code>$("#cart-items").on("click", "li a", function(){
  var removeItemID = $(this).parent().attr("id");
  var listCount = $("#cart-items").children().length;

  if(listCount == 1) {
     $("fieldset").eq("+ listCount +").children().val("");
     $("fieldset input").eq(0).val("row_new_0"); 
     $(this).parent().replaceWith("&lt;li id=\"emptycart\"&gt;You have no items in your cart.&lt;/li&gt;")
  } else {
     alert(listCount);
     $("fieldset").eq("+ listCount +").remove();
     $(this).parent().remove();     
  }
});
</code></pre>

<p>When this runs, it removes my Display Item (List Element) but the fieldset from my form does not get removed. Any help would be greatly appreciated. Thank you in advanced!</p>
