Bind a click event to an element, but I encountered a problem that when I execute some ajax requests, the click event becomes invalid
For example, my paging is an ajax request, but it is generated when I click on the next page. There is no click event for element a
In fact, the reason is very simple
ajax loading content is an operation after $(document).ready(). At this time, when binding the function , the found element set does not include the content loaded by ajax, so there is no problem with the original one, and the later loaded ones are not bound
There are two solutions:
1. In the ajax request Rebind after success
2. Use the live method