views:

43

answers:

1

I want to add a set of lists to the children of another DOM element:

    var req_subsets = $("#req_subsets");

    $.each(subsets, function(index, subset) {

        var subset_list = $("<ul></ul>");

        // add DOM elements to subset_list

        req_subsets.append(subset_list);
    });

However, only one DOM element is ever added. This makes me suspect that when I assign a new value to subset_list, the old one is overwritten. If that is the problem, how do I avoid it? If not, what else am I doing wrong?

UPDATE: I changed something else, and I'm almost entirely certain that this is fixed.

A: 

I strongly recommend using Easy DOM Creation for this kind of things

but you can try this anyway fixed:

var req_subsets = $("#req_subsets");

$.each(subsets, function(index, subset) {

    var subset_list = $("<ul></ul>");

    // add DOM elements to subset_list

    subset.append(subset_list);
});
GerManson