Suppose in code with the help of JQuery there is an event of clicking on the id = 'button' element:
$(function (){$('#button').click(function() { alert('на меня нажали'); }); });
The code works fine and everyone is happy, but if the #button element was removed and re-created using .innerHTML or for example its id was changed to another, and then replaced back to #button, the above written function stops working. As if jQuery thought that #button is no more. Question: what is this phenomenon and how can it be avoided? If not, how can you reanimate the function without refreshing the page?
added : the question intersects with this question, but I have a question about how to make the function work after the changes or find an alternative, and there is a question about the principle of the work of "delegation (delegation) and rebinding). Still can help in resolving this issue.