Home > Web Front-end > JS Tutorial > How to realize the coexistence of single click and double click in javascript_javascript skills

How to realize the coexistence of single click and double click in javascript_javascript skills

WBOY
Release: 2016-05-16 16:27:27
Original
1508 people have browsed it

The example in this article describes the method of javascript to achieve the coexistence of single click and double click. Share it with everyone for your reference. The specific analysis is as follows:

In the process of web development, we often encounter such a problem, registering a double-click event for a link, or registering a click or double-click event on a button or other element at the same time. At this time, we found that the double-click event in the web page Events never seem to work because when we click once, they are intercepted by a hyperlink or click event. This article describes a specific method on how to solve this technical problem. The implementation principle of this solution is that both single-click and double-click events call the same method. We determine whether it is a single-click or double-click event based on the time between two mouse clicks. When the click event comes, do not call it first, wait for a short period of time, after this period of time, if the next click does not come, start calling the corresponding operation of the click, if there is the next click, call the double click.
For detailed description, please join the code list below:

Copy code The code is as follows:

 
  javascript 实现单击和双击并存
 
 
 
 
 

 
 


                            onclick=" handleWisely(event.type)"
                ondblclick=" handleWisely(event.type)"
                style=" color: blue; font-family: arial; cursor: hand" >
          点击一下看看结果:
     

     


       
     

         
             
                 
             
             
                 
             
         

                    事件模式:
                 

                     
                 

     

 

希望本文所述对大家的javascript程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template