I have a function that generates div boxes. Where the box should be located on the page is determined by the last created box offset values. On the boxes is a button when clicked the removes the box. However, I want the rest of the boxes to stay in place, which won’t happen because the boxes that’s created after the removed one relies on the offset of the removed box. So when I remove a box the box order collapses.
So, I guess I want a way to hard code the offset values I get from the previous box so they will remain even after I delete the previous box.
Below is a sample of my code. I hope it is enough:
…
box.offset({
left: prev.offset().left + 15,
top: prev.offset().top + 15 });
…
I think the previous version of the question with more code and link to working example was a better idea :).
Set
position: absoluteon the “window” div element so the position won’t be modified when other DIV is removed.HERE is the example.