insertAfter inside a loop.
I have a number of hidden divs in a form, and I am using insertAfter to display them, dynamically, in a particular order.
So I have a for loop and an array of div id's, and I call insertAfter within the loop. Is there a way to insert the divs one at a time, so that div1 for example slides down, then div2 slides down after div1 is in place? I've looked at queue and animate, but I have not gotten them to work correctly. Although the order is correct in the function below, everything happens all at once rather than consecutively.
Here is the function I am passing the array to:
function InsertControls(items) {
for (var i = 0; i < items.length; i++) {
var obj = $('#' + items[i][0]);
var obj2 = $('#' + items[i][1]);
obj.delay(10).slideDown(400, 'swing', obj.insertAfter(obj2));
}
}
Thanks,
David