How can I clone dropdown list(combobox) with selected option?
jquery .clone method is not working in firefox for selected option.
I have a
var $orginalDiv = $('#myDiv');
var $clonedDiv = $orginalDiv.clone();
//get original selects into a jq object
var $originalSelects = $orginalDiv.find('select');
$clonedDiv.find('select').each(function(index, item) {
//set new select to value of old select
$(item).val( $originalSelects.eq(index).val() );
});
Try it here at jsfiddle
Can you implement a button to clone the drop downs?
Hi you have a customedropdown with some image mask then simple clone will not display a selected value, for that you have to first assign a selected value of one dropdown to second drop down, and then call a change event implicitly like following. $('select[id*=cstate]').val($("select[id*=state]").val()); $("#cstate").change();