3

I have two comboboxes that I need to populate with the same information when another combobox data is changed.

However, when I use the .append() method, it's apparent that it only executes the latest append call. Here is the code:

    $('.sc-days').change(function () {
        var scedo = $('.sc-edo');
        var sclpo = $('.sc-lpo');
        var selected = $(".sc-days option:selected");
        scedo.append(selected);
        sclpo.append(selected);
    });

When this is run, only 'sclpo' will be populated. You can see the results here. http://jsfiddle.net/DF42s/

4

1 回答 1

5

假设您打算附加原件的副本,请执行以下操作:

$('.sc-days').change(function () {
    var selected = $(".sc-days option:selected");
    $('.sc-edo').append(selected.clone());
    $('.sc-lpo').append(selected.clone());
});
于 2014-06-16T03:36:49.390 回答