detach elements and reattach them later