Listen to double click not click

前端 未结 6 2044
情歌与酒
情歌与酒 2020-12-15 08:55

I\'m just wondering why click event happening when I dbclick an element?

I have this code:(JSBIN)

HTML

&l         


        
6条回答
  •  甜味超标
    2020-12-15 09:43

    To answer the revised question (How to mutually exclusively handle click and dblclick) you have to delay the click event until dblclick is no longer possible. This gives a slight lag (e.g., 500ms) to click handling but otherwise there is no way for the DOM to predict whether a second click will be arriving.

    An example script is in this answer: https://stackoverflow.com/a/11057483/43217

提交回复
热议问题