Add Event (jquery)

Source: Internet
Author: User

You need to be careful when adding the same events as the boxes inside the box.

Such as:

There seems to be no big problem from the surface, but there is a fatal problem, that is, every time you click on the box, the test will add a click event, and the added click event will not overwrite each other, it can be added multiple times, unless it is the same event, which will cause The Click event of test is executed several times during the subsequent click, similar to the second click Execution two times, the third click executes three times ...

So you need to use only one event ().

  one()The function is used to bind one-time event handlers for each of the events that match an element .

The simplest approach is to:

Alternatively, before adding a click event to test, remove the Click event that he already has, either off or unbind, and the Unbind bottom is also implemented using off.

  

Add Event (jquery)

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.