I have two divs, one that holds some stuff and the other with all possible stuff. Clicking on one of the divs will transfer items to the other div. The code I came up with is:
$(#holder > *).each(function() {
$(this).click(function(e) {
$(this).remove();
$(#bucket).append(this);
});
});
$(#bucket > *).each(function() {
$(this).click(function(e) {
$(this).remove();
$(#holder).append(this);
});
});
This one works perfectly, except that the event handlers need to be refreshed once I append or remove elements. What I mean is, if I first click on an element, it gets added to the other div, but if I click on this element again, nothing happens. I can do this manually but is there a better way to achieve this?