You can use the stop event of the slider to calculate how many divs you need to add or remove. I am just adding and subtracting div elements but you could easily clone as well.
Demo: http://jsfiddle.net/lucuma/ggC8s/
$(function() {
$("#slider-vertical").slider({
orientation: "vertical",
range: "min",
min: 0,
max: 100,
value: 0,
stop: function(event, ui) {
$("#amount").val(ui.value);
var diff = ui.value - $('#content div').length;
if (ui.value == 0) {
$('#content div').remove();
} else if (diff < 0) {
$('#content div:gt(' + ($('#content div').length + diff - 1) + ')').remove();
} else {
var i = diff;
while (i--) {
$('#content').append('<div>div</div>');
}
}
},
slide: function(event, ui) {
$("#amount").val(ui.value);
}
});
});
As an alternative you could remove all the divs and regenerate them instead of calculating the deltas.
Demo: http://jsfiddle.net/lucuma/ggC8s/3/
$(function() {
$("#slider-vertical").slider({
orientation: "vertical",
range: "min",
min: 0,
max: 100,
value: 0,
stop: function(event, ui) {
var diff = ui.value;
$('#content div').remove();
while (diff--) {
$('#content').append('<div>div</div>');
}
},
slide: function(event, ui) {
$("#amount").val(ui.value);
}
});
});