Reputation: 926
I have a select list where one option is selected by default when the page loads.
When a different option is selected, the html I view in Firebug does not change.
I have a button that makes copies of this element, and would like the copies to have the same selected value as this one, but they all have the default value selected.
How can I make the copies have the same selected values as the original?
Upvotes: 0
Views: 487
Reputation: 39649
When you clone the element you should be able to set the cloned select's value to that of the original. E.g.,
var $select = $('#my-select'),
$clone = $select.clone().val($select.val());
// I don't know where you really want the clone, just an example...
$clone.insertAfter($select);
Upvotes: 2