I used to manually bind the event handler when I added it. However, this function has been added to the new jquery version. We don't need to worry about it anymore.
Reference: http://api.jquery.com/live/
Previously, we defined events. For example, we wrote a click event for the element definition as follows:
CopyCodeThe Code is as follows: $ ('input'). Click (function (){
// Process the code
});
OrCopy codeThe Code is as follows: $ ('. clickme'). BIND ('click', function (){
// Bound handler called.
});
However, this can only be used to define events for loaded elements. elements that are inserted later must be bound separately. Even if you use jquery's clone function, it cannot replicate events (so far, I still have no idea why it is defined as so, whether it cannot be copied or deliberately processed, to prevent some exceptions, it is still necessary to analyze the jquerySource code).
Now, you can easily use live,
$ ('. Clickme '). live ('click', function () {// live handler called .}); in this way, even if you insert the elements dynamically behind it, it will be bound to an event, $ ('body '). append ('<Div class = "clickme"> another target </div> ');