Updating the HTML is in reality replacing the HTML. That means removing everything that's in the DOM, event handlers included.
Then the new HTML is added, effectively replacing the old HTML, only that the old event handlers haven't been re-added.
A common solution to this problem is to use event delegation. That is, add an event handler in a node that's a parent of what's getting replaced, and listen for events that have an e.target
(that is, the node that the event originated on) which satisfies the child node you want.
The difference is that new nodes will still match the check for nodes like such and such, and won't be removed when replacing their children.
You can read some more about event delegation here: Getting Over jQuery