Dynamically generated element action bindings, how jquery 1.9 implements

Source: Internet
Author: User

Added Live () after 1.7
was removed after 1.9.

Online says you can use on () instead

You can actually bind the action on a dynamically generated element, without effect, to solve the absolute method (with the low version of jquery this way, do not say: )

For:

Before a man answered a question like this, I'll put a sticker on it for you:

You should use the on event to bind so that the newly inserted element will trigger the Click event. http://api.jquery.com/on/

$ (function () {  $ ("body"). On ("click", '. a ', function () {    alert (' OK ');  });  $ ('. B '). Click (function () {    $ ("<class=' A ' ></div>"). InsertAfter ($ (this)) ;}) 

Dynamically generated element action bindings, how jquery 1.9 implements

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.