Quick Solution for repeated jquery event binding _ jquery-js tutorial

Source: Internet
Author: User
This article mainly introduces the quick solution for repeated jquery event binding. If you need a friend, please refer to it and hope to help you. One $. fn. live repeat binding

Solution:Use the die () method to unbind all events bound to the element before binding the live () method, and then bind new events using the live () method.

The Code is as follows:


// Unbind from the die () method and then use live () Binding
$ ("# SelectAll"). die (). live ("click", function (){
// Event Running code
});


Second click and other events

Solution:The unbind ("click") method is used to unbind the Bound event and then bind the new event. That is, the original event on the object is removed before the event is bound to the object.

Complete Test code:

The Code is as follows:



Repeat the binding trigger button(Click this button twice or more to trigger repeated binding, and then click the button below to see the result)



Click to repeat the binding test button
Click to bind a test button
Repeat the test button in live.
Live binds a test button


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.