Reputation: 703
I'm trying to to duplicate a div after changing a select like in this link : http://jsfiddle.net/ranell/mN6nm/5/ I have [object] instead of my lists :( Any idea?
Thanks
Upvotes: 0
Views: 115
Reputation: 14479
Try this: (jsFiddle):
$(document).ready(function () {
var original = $("#dvCatGr");
$('#sctChambre').change(function() {
var total = parseInt($(this).val());
$('#dvCat').empty();
for (var i = 0; i < total; i++) {
$("#dvCat").append($(original).clone().attr("id", "dvCatGr"+ i));
}
});
});
Upvotes: 1
Reputation: 207983
Something like this jsFiddle example?
$('#sctChambre').change(function() {
var total = parseInt($(this).val());
for (i = 0; i < total; i++) {
$('#dvCat').after($('#dvCatGr').clone().attr('id', 'c' + i));
}
});
Upvotes: 2