How to Implement the coexistence of click and double-click in javascript _ javascript skills

Source: Internet
Author: User
This article describes how to implement the coexistence of click and double-click in javascript. It is a very practical technique to determine the effect of click and double-click by defining the interval of the second click, for more information, see the examples in this article. Share it with you for your reference. The specific analysis is as follows:

During webpage development, we often encounter such a problem: register a double-click event for a link, or register a click or double-click event with a button or other elements, at this time, we found that double-click events on the Web page never seem to work, because when we click once, they are intercepted by hyperlinks or click events, this article describes how to solve this technical problem. The implementation principle of this solution is to call the same method for clicking an event or double-click an event. We can determine whether to click or double-click an event based on the interval between two mouse clicks. When you click an event, do not call it. Wait for a short period of time. After this period of time, if you do not have the next click, start to call and click the corresponding operation, double-click is called for the next click.
For details, see the following code list:

The Code is as follows:



Click and double-click in javascript





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.