The solution of Jquery binding the Click event to the newly inserted node is invalid. jqueryclick

Source: Internet
Author: User

The solution of Jquery binding the Click event to the newly inserted node is invalid. jqueryclick

1. Some people say that Live is used. In fact, the latest Jquery does not support Live anymore. The solution to live is as follows:

You can read this or not, but you can do it by knowing what you want. The following describes the ON method.

Live: Introduction to Live

2. Some people use ON to solve the problem. This solution is basically correct.

On: On Introduction, can solve the problem

The On method can basically solve the problem, but you should also make a choice based On your specific situation. Not everyone's code is as simple as described in the above case. However, the case changes.

I did this and finally solved the problem.

I have a UL label that is static, that is, it was not dynamically added later.

Then I added images dynamically.

<Li> <a href = "#"...> link </a> </li>.

I chose the method below.

$ ("# Subul "). on ('click', 'Li> A', function (e) {// cancel bubbling // var e = e | window. event; // e. stopPropagation (); alert ("asssss"); var areaid = this. attributes. getNamedItem ("id "). nodeValue; alert (areaid); $ ("# subul> li> "). removeClass ("smallBtSelected"); $ ("#" + areaid ). addClass ("smallBtSelected ");})

The above Jquery solution to binding the Click event to the newly inserted node is to share all the content with you in the editor. I hope to give you a reference, and I hope you can also provide more support to the customer center.

Related Article

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.