How does jquery bind events to dynamically created nodes?

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.