How do I add events to dynamically created nodes? For example, in the following case, if you want to add a click event for a node with a dynamically generated id of del, you can write it as follows:
$ ('# Del'). live ('click', function () {alert ('obtained ');});
In fact, we mainly use the live method. For details about this method, refer to this article: jQuery adds event responses to dynamically generated content (jquery live Method Introduction)
Articles you may be interested in
- JQuery adds Event Response to dynamically generated content (jquery live Method Introduction)
- Simple Example of php getting webpage content through socket
- How to Use jquery to control the display of user-uploaded pictures with too much width
- How does jquery bind events to dynamically created nodes?
- Js obtains the height of the scroll bar from the top and bottom of the browser. It is compatible with ie and firefox.
- Jquery drop-down menu (ultra-simple and practical, compatible with mainstream browsers such as IE and firefox)
- Jquery checks whether the page has been loaded with the jquery File
- Js dynamically creates html content