When you do
jquery looks in the dom, and finds elements that currently exist in the dom which match your selector. Then, once it has that element(or list of elements), it tells those elements that they need to run your function when they get clicked.
So, if you later add new elements to the dom, these new elements will not know that they need to run your function when they get clicked.
And that's your problem. You are removing the elements, and then creating new ones. Even though the new elements may be similar, and even have the same id, they are different elements.
You could do one of the following
-dont remove the old elements that have the click event handlers. Just update thier contents.
-keep doing what you're doing, but make sure to re assign click event handlers to the new elements after inserting them into the dom.
-take a look at jquery's live() method, which does a lot of work behind the scenes so that you don't have the above problem.