prog_24
prog_24

Reputation: 800

Multiple append not working jQuery

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/

Upvotes: 3

Views: 805

Answers (1)

cookie monster
cookie monster

Reputation: 10972

Assuming you intended to append copies of the original, do this:

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

Upvotes: 5

Related Questions