15. Use the One () method to bind an element's one-time event

Source: Internet
Author: User

one()The method can bind an element to any valid event, but the event that this method binds is only fired once, and its invocation format is as follows:

$(selector).one(event,[data],fun)

The parameter event is the name of the events, and data is what is carried when the event is triggered, and fun is the function that is executed when the event is triggered.

For example, using the one method binding <div> element's Click event, in the function that the event executes, the number of executions is cumulative and the number is displayed in the page as shown in:

Effects displayed in the browser:

As you can see, because the one() click event of the method binding <div> element is used, because the event function can only be executed once, the execution completes, no matter what click, no longer fires.

15. Use the One () method to bind an element's one-time event

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.