The following example shows how jquery binds events to dynamically created nodes:
$ ("# Table "). append ("<a href = 'javascript:; 'class = 'del '> Delete </a>"); $ (". del "). click (function () {alert ("get to pull ");})
The above Code does not work. If you want the above Code to achieve the goal, write it as follows:
$ ("# Table "). append ("<a href = 'javascript:; 'class = 'del '> Delete </a>"); $ (". del "). live ("click", function () {alert ("retrieved ");});
Articles you may be interested in
- JQuery adds Event Response to dynamically generated content (jquery live Method Introduction)
- Add events to content dynamically generated by jquery
- How does Jquery bind events to elements?
- Js dynamically creates html content
- Summary of jquery's method for moving dom nodes
- Summary of how jquery copies dom nodes
- Jquery simulates Mouse clicking events
- Jquery checks whether the page has been loaded with the jquery File