You need to clone the desired item, set the selected value for the clone, and then add the clone.
function addselect(s){ // Store the block in a variable var $block = $('#product_categories > .category_block:last'); // Grab the selected value var theValue = $block.find(':selected').val(); // Clone the block var $clone = $block.clone(); // Find the selected value in the clone, and remove $clone.find('option[value=' + theValue + ']').remove(); // Append the clone $block.after($clone); set_add_delete_links(); return false; }
UPDATE: Modified to add HTML to the question.
Note that the identifier of the select element is cloned, which means that you have 2 elements with the same identifier. It is forbidden. You will need to get rid of the identifier or change it in the clone to some other value.
You can do something similar before adding a clone:
// Grab the select in the clone var $select = $clone.find('select'); // Update its ID by concatenating theValue to the current ID $select.attr('id', $select.attr('id') + theValue);
source share